go module下执行单元测试错误

go版本升级到1.12.3后执行github上别人一个开源代码的单元测试,发现提示:
# go test
go: cannot find main module; see ‘go help modules’

如果不启用go module也就是将GO11MODULE环境变量设置为auto就没这个问题。问题原因是没有生成go.mod等文件,具体做法是:
go mod init hanjam/zaplog
go test

Leave a Reply

Your email address will not be published. Required fields are marked *