最佳答案
目录结构是:
src
src/pkg
src/pkg/t1.go
src/pkg/t1_test.go
package pkg
import (
"fmt"
)
func SayHI(){
fmt.Println("this is t1")
}
package pkg
import (
"testing"
)
func TestXYZ(t *testing.T) {
SayHI()
}
从目录 src/pkg
的命令行调用 go test
go test t1_test.go
./t1_test.go:8: undefined: SayHI
FAIL command-line-arguments [build failed]
但函数是存在的
谢谢你的提示