dongzhuo7291 2017-11-28 17:17 采纳率: 100%
浏览 2588
已采纳

Go测试失败,显示“无法加载软件包构建约束,排除了所有Go文件”

当我运行这个命令时:

go test -tags integration $(go list ./... | grep -v /vendor/)

go测试失败,因为有些软件包的所有测试都标有:// +build !integration

can't load package: build constraints exclude all Go files

在这种情况下,有没有一种方法可以让 go test 忽略这些包?谢谢!

  • 写回答

1条回答 默认 最新

  • dongyigua4468 2017-11-28 18:01
    关注

    You will only get that error if all the files in the package are excluded by your build constraints, not just the test files. If that's what you want, just add a single package file with no code and the package will still be able to be loaded. For example, many packages put their package level docs in a separate file, which you could use to always have a valid package:

    // Package foo does foo
    package foo
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?