Change-Id: I79854419091d6c5c5c2922a1f45a3c5589673f11
Reviewed-on: https://go-review.googlesource.com/c/go/+/435138
Run-TryBot: xie cui <
523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
// involved in module graph construction, many *.zip files
// will never be requested.
name := info.Name()
- if strings.HasSuffix(name, ".mod") {
- v := strings.TrimSuffix(name, ".mod")
+ if v, found := strings.CutSuffix(name, ".mod"); found {
if v != "" && module.CanonicalVersion(v) == v {
list = append(list, v)
}
}
}
for ref, hash := range refs {
- if strings.HasSuffix(ref, "^{}") { // record unwrapped annotated tag as value of tag
- refs[strings.TrimSuffix(ref, "^{}")] = hash
+ if k, found := strings.CutSuffix(ref, "^{}"); found { // record unwrapped annotated tag as value of tag
+ refs[k] = hash
delete(refs, ref)
}
}
func checkSumDB(mod module.Version, h string) error {
modWithoutSuffix := mod
noun := "module"
- if strings.HasSuffix(mod.Version, "/go.mod") {
+ if before, found := strings.CutSuffix(mod.Version, "/go.mod"); found {
noun = "go.mod"
- modWithoutSuffix.Version = strings.TrimSuffix(mod.Version, "/go.mod")
+ modWithoutSuffix.Version = before
}
db, lines, err := lookupSumDB(mod)
var sourceFile string
var coverFile string
var key string
- if strings.HasSuffix(file, ".cgo1.go") {
+ if base, found := strings.CutSuffix(file, ".cgo1.go"); found {
// cgo files have absolute paths
- base := filepath.Base(file)
+ base = filepath.Base(base)
sourceFile = file
- coverFile = objdir + base
- key = strings.TrimSuffix(base, ".cgo1.go") + ".go"
+ coverFile = objdir + base + ".cgo1.go"
+ key = base + ".go"
} else {
sourceFile = filepath.Join(p.Dir, file)
coverFile = objdir + file