diff options
| author | Kir Kolyshkin <kolyshkin@gmail.com> | 2025-11-07 11:07:16 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-02-12 09:31:15 -0800 |
| commit | 31a03fe20c5361924622fd4cc92edcd08ba07072 (patch) | |
| tree | 9ba7544472cbc5a534b71764e894a08bd51da68d /src/cmd | |
| parent | 2a1d605e7f5a0f8870abb9cc26edf27db3ad5452 (diff) | |
| download | go-31a03fe20c5361924622fd4cc92edcd08ba07072.tar.xz | |
cmd/go/internal/modindex: eliminate duplicated vars
There is no need to have two sets of the same slices.
The names are chosen to be the same as in ../imports.
Change-Id: I92dca46127e25b5226cce3cc11749cd5957ad609
Reviewed-on: https://go-review.googlesource.com/c/go/+/718800
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/go/internal/modindex/build.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/cmd/go/internal/modindex/build.go b/src/cmd/go/internal/modindex/build.go index 053e04dfe5..c0acb8ff58 100644 --- a/src/cmd/go/internal/modindex/build.go +++ b/src/cmd/go/internal/modindex/build.go @@ -182,9 +182,10 @@ func fileListForExt(p *build.Package, ext string) *[]string { } var ( - slashSlash = []byte("//") - slashStar = []byte("/*") - starSlash = []byte("*/") + bSlashSlash = []byte("//") + bSlashStar = []byte("/*") + bStarSlash = []byte("*/") + bPlusBuild = []byte("+build") ) var dummyPkg build.Package @@ -296,11 +297,6 @@ func cleanDecls(m map[string][]token.Position) ([]string, map[string][]token.Pos } var ( - bSlashSlash = slashSlash - bStarSlash = starSlash - bSlashStar = slashStar - bPlusBuild = []byte("+build") - goBuildComment = []byte("//go:build") errMultipleGoBuild = errors.New("multiple //go:build comments") @@ -382,7 +378,7 @@ Lines: end = len(content) - len(p) continue Lines } - if !bytes.HasPrefix(line, slashSlash) { // Not comment line + if !bytes.HasPrefix(line, bSlashSlash) { // Not comment line ended = true } @@ -399,9 +395,9 @@ Lines: Comments: for len(line) > 0 { if inSlashStar { - if i := bytes.Index(line, starSlash); i >= 0 { + if i := bytes.Index(line, bStarSlash); i >= 0 { inSlashStar = false - line = bytes.TrimSpace(line[i+len(starSlash):]) + line = bytes.TrimSpace(line[i+len(bStarSlash):]) continue Comments } continue Lines |
