1 Star 0 Fork 0

wuguanyang/goconvey

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
goconvey_1_8.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
Zvi Effron 提交于 2019-03-29 11:20 . Keep supporting Go versions < 1.9
// +build !go1.9
// To work correctly with out of GOPATH modules, some functions needed to
// switch from using go/build to golang.org/x/tools/go/packages. But that
// package depends on changes to go/types that were introduced in Go 1.9. Since
// modules weren't introduced until Go 1.11, users of Go 1.8 or below can't be
// using modules, so they can continue to use go/build.
package main
import (
"go/build"
"strings"
)
// This method exists because of a bug in the go cover tool that
// causes an infinite loop when you try to run `go test -cover`
// on a package that has an import cycle defined in one of it's
// test files. Yuck.
func testFilesImportTheirOwnPackage(packagePath string) bool {
meta, err := build.ImportDir(packagePath, build.AllowBinary)
if err != nil {
return false
}
for _, dependency := range meta.TestImports {
if dependency == meta.ImportPath {
return true
}
}
return false
}
func resolvePackageName(path string) string {
pkg, err := build.ImportDir(path, build.FindOnly)
if err == nil {
return pkg.ImportPath
}
nameArr := strings.Split(path, endGoPath)
return nameArr[len(nameArr)-1]
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuguanyang/goconvey.git
git@gitee.com:wuguanyang/goconvey.git
wuguanyang
goconvey
goconvey
master

搜索帮助