commit 2fecd78ff3584685aa5998ab29cbb739bcb73c8a Author: a.pivkin Date: Wed Jun 19 09:11:01 2024 +0300 the first one diff --git a/calculator/calculator.go b/calculator/calculator.go new file mode 100644 index 0000000..28d9f52 --- /dev/null +++ b/calculator/calculator.go @@ -0,0 +1,5 @@ +// Package calculator does simple calculations. +package calculator // Add takes two numbers and returns the result of adding them together. +func Add(a, b float64) float64 { + return a + b +} diff --git a/calculator/calculator_test.go b/calculator/calculator_test.go new file mode 100644 index 0000000..4ac282c --- /dev/null +++ b/calculator/calculator_test.go @@ -0,0 +1,16 @@ +package calculator_test + +import ( + "calculator" + "testing" +) + +func TestAdd(t *testing.T) { + t.Parallel() + var want float64 = 4 + got := calculator.Add(2, 2) + if want != got { + t.Errorf("want %f, got %f", want, got) + } +} + diff --git a/calculator/go.mod b/calculator/go.mod new file mode 100644 index 0000000..af2daa6 --- /dev/null +++ b/calculator/go.mod @@ -0,0 +1,4 @@ +module calculator + +go 1.22.4 +