Trying to run "go test sum_test.go" returns an error:
./sum_test.go:18:13: undefined: SumInt8 FAIL command-line-arguments [build failed]
I'm taking an introductory course in golang. Our teacher distributed a code-file, sum.go, and a testing-file, sum_test.go. Trying to run "go test" on sum_test.go returns the error above. The code runs fine on our teachers mac, and he's having difficulties recreating the problem. Here's my go environment settings: https://pastebin.com/HcuNVcAF
sum.go
package sum
func SumInt8(a, b int8) int8 {
return a + b
}
func SumFloat64(a, b float64) float64 {
return a + b
}
sum_test.go
package sum
import "testing"
// Check https://golang.org/ref/spec#Numeric_types and stress the
limits!
var sum_tests_int8 = []struct {
n1 int8
n2 int8
expected int8
}{
{1, 2, 3},
{4, 5, 9},
{120, 1, 121},
}
func TestSumInt8(t *testing.T) {
for _, v := range sum_tests_int8 {
if val := SumInt8(v.n1, v.n2); val != v.expected {
t.Errorf("Sum(%d, %d) returned %d, expected %d",
v.n1, v.n2, val, v.expected)
}
}
}
I see no particular errors, so I expected "go test sum_test.go" to run, and succeed. However it seems it can't find the method SumInt8 in sum.go.