我对 go lang 的内置测试有疑问。
我一直收到这个错误。
> go test
> can't load package: package .: found packages main (calculator.go) and calculator (calculator_test.go) in
计算器.go
package main
func main() {
}
计算器_test.go
package calculator
import "testing"
func TestAdd(t *testing.T) {
result := Add(1, 3)
if result != 4 {
t.Fail()
}
}
最佳答案
你有
package main
func main() {}
在文件 calculator.go
中。
和
package calculator
在文件 calculator_test.go
中。
应该都是
package main
关于Golang 测试 > 无法加载包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27596539/