Skip to content

Commit 1c38ee5

Browse files
committed
cmd: remove a few unused parameters
They all seem pretty low-risk, and the overall diff is small. While at it, remove one in go/build too. Change-Id: I31df52c1c97d843b06f6c1dc63462d390db4470d Reviewed-on: https://go-review.googlesource.com/c/go/+/203607 Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 91f3997 commit 1c38ee5

6 files changed

Lines changed: 20 additions & 21 deletions

File tree

src/cmd/go/internal/envcmd/env.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func runEnv(cmd *base.Command, args []string) {
237237
base.Fatalf("go env -w: arguments must be KEY=VALUE: invalid argument: %s", arg)
238238
}
239239
key, val := arg[:i], arg[i+1:]
240-
if err := checkEnvWrite(key, val, env); err != nil {
240+
if err := checkEnvWrite(key, val); err != nil {
241241
base.Fatalf("go env -w: %v", err)
242242
}
243243
if _, ok := add[key]; ok {
@@ -259,7 +259,7 @@ func runEnv(cmd *base.Command, args []string) {
259259
}
260260
del := make(map[string]bool)
261261
for _, arg := range args {
262-
if err := checkEnvWrite(arg, "", env); err != nil {
262+
if err := checkEnvWrite(arg, ""); err != nil {
263263
base.Fatalf("go env -u: %v", err)
264264
}
265265
del[arg] = true
@@ -330,7 +330,7 @@ func printEnvAsJSON(env []cfg.EnvVar) {
330330
}
331331
}
332332

333-
func checkEnvWrite(key, val string, env []cfg.EnvVar) error {
333+
func checkEnvWrite(key, val string) error {
334334
switch key {
335335
case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOTOOLDIR":
336336
return fmt.Errorf("%s cannot be modified", key)

src/cmd/go/internal/load/pkg.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ func loadImport(pre *preload, path, srcDir string, parent *Package, stk *ImportS
593593
return setErrorPos(perr, importPos)
594594
}
595595
if mode&ResolveImport != 0 {
596-
if perr := disallowVendor(srcDir, parent, parentPath, path, p, stk); perr != p {
596+
if perr := disallowVendor(srcDir, path, p, stk); perr != p {
597597
return setErrorPos(perr, importPos)
598598
}
599599
}
@@ -1321,11 +1321,10 @@ func findInternal(path string) (index int, ok bool) {
13211321
return 0, false
13221322
}
13231323

1324-
// disallowVendor checks that srcDir (containing package importerPath, if non-empty)
1325-
// is allowed to import p as path.
1324+
// disallowVendor checks that srcDir is allowed to import p as path.
13261325
// If the import is allowed, disallowVendor returns the original package p.
13271326
// If not, it returns a new package containing just an appropriate error.
1328-
func disallowVendor(srcDir string, importer *Package, importerPath, path string, p *Package, stk *ImportStack) *Package {
1327+
func disallowVendor(srcDir string, path string, p *Package, stk *ImportStack) *Package {
13291328
// The stack includes p.ImportPath.
13301329
// If that's the only thing on the stack, we started
13311330
// with a name given on the command line, not an

src/cmd/go/internal/sumdb/server.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
8080
escPath, escVers := mod[:i], mod[i+1:]
8181
path, err := module.UnescapePath(escPath)
8282
if err != nil {
83-
reportError(w, r, err)
83+
reportError(w, err)
8484
return
8585
}
8686
vers, err := module.UnescapeVersion(escVers)
8787
if err != nil {
88-
reportError(w, r, err)
88+
reportError(w, err)
8989
return
9090
}
9191
id, err := s.ops.Lookup(ctx, module.Version{Path: path, Version: vers})
9292
if err != nil {
93-
reportError(w, r, err)
93+
reportError(w, err)
9494
return
9595
}
9696
records, err := s.ops.ReadRecords(ctx, id, 1)
@@ -137,7 +137,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
137137
start := t.N << uint(t.H)
138138
records, err := s.ops.ReadRecords(ctx, start, int64(t.W))
139139
if err != nil {
140-
reportError(w, r, err)
140+
reportError(w, err)
141141
return
142142
}
143143
if len(records) != t.W {
@@ -159,7 +159,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
159159

160160
data, err := s.ops.ReadTileData(ctx, t)
161161
if err != nil {
162-
reportError(w, r, err)
162+
reportError(w, err)
163163
return
164164
}
165165
w.Header().Set("Content-Type", "application/octet-stream")
@@ -172,7 +172,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
172172
// Otherwise it is an internal server error.
173173
// The caller must only call reportError in contexts where
174174
// a not-found err should be reported as 404.
175-
func reportError(w http.ResponseWriter, r *http.Request, err error) {
175+
func reportError(w http.ResponseWriter, err error) {
176176
if os.IsNotExist(err) {
177177
http.Error(w, err.Error(), http.StatusNotFound)
178178
return

src/cmd/go/internal/work/buildid.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"cmd/go/internal/base"
1616
"cmd/go/internal/cache"
1717
"cmd/go/internal/cfg"
18-
"cmd/go/internal/load"
1918
"cmd/go/internal/str"
2019
"cmd/internal/buildid"
2120
)
@@ -421,7 +420,7 @@ func (b *Builder) fileHash(file string) string {
421420
// during a's work. The caller should defer b.flushOutput(a), to make sure
422421
// that flushOutput is eventually called regardless of whether the action
423422
// succeeds. The flushOutput call must happen after updateBuildID.
424-
func (b *Builder) useCache(a *Action, p *load.Package, actionHash cache.ActionID, target string) bool {
423+
func (b *Builder) useCache(a *Action, actionHash cache.ActionID, target string) bool {
425424
// The second half of the build ID here is a placeholder for the content hash.
426425
// It's important that the overall buildID be unlikely verging on impossible
427426
// to appear in the output by chance, but that should be taken care of by

src/cmd/go/internal/work/exec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ func (b *Builder) build(a *Action) (err error) {
395395
bit(needCompiledGoFiles, b.NeedCompiledGoFiles)
396396

397397
if !p.BinaryOnly {
398-
if b.useCache(a, p, b.buildActionID(a), p.Target) {
398+
if b.useCache(a, b.buildActionID(a), p.Target) {
399399
// We found the main output in the cache.
400400
// If we don't need any other outputs, we can stop.
401401
// Otherwise, we need to write files to a.Objdir (needVet, needCgoHdr).
@@ -1171,7 +1171,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
11711171
// link is the action for linking a single command.
11721172
// Note that any new influence on this logic must be reported in b.linkActionID above as well.
11731173
func (b *Builder) link(a *Action) (err error) {
1174-
if b.useCache(a, a.Package, b.linkActionID(a), a.Package.Target) || b.IsCmdList {
1174+
if b.useCache(a, b.linkActionID(a), a.Package.Target) || b.IsCmdList {
11751175
return nil
11761176
}
11771177
defer b.flushOutput(a)
@@ -1404,7 +1404,7 @@ func (b *Builder) linkSharedActionID(a *Action) cache.ActionID {
14041404
}
14051405

14061406
func (b *Builder) linkShared(a *Action) (err error) {
1407-
if b.useCache(a, nil, b.linkSharedActionID(a), a.Target) || b.IsCmdList {
1407+
if b.useCache(a, b.linkSharedActionID(a), a.Target) || b.IsCmdList {
14081408
return nil
14091409
}
14101410
defer b.flushOutput(a)

src/go/build/build.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,14 @@ func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Packa
592592
return p, fmt.Errorf("import %q: cannot import absolute path", path)
593593
}
594594

595-
gopath := ctxt.gopath() // needed by both importGo and below; avoid computing twice
596-
if err := ctxt.importGo(p, path, srcDir, mode, gopath); err == nil {
595+
if err := ctxt.importGo(p, path, srcDir, mode); err == nil {
597596
goto Found
598597
} else if err != errNoModules {
599598
return p, err
600599
}
601600

601+
gopath := ctxt.gopath() // needed twice below; avoid computing many times
602+
602603
// tried records the location of unsuccessful package lookups
603604
var tried struct {
604605
vendor []string
@@ -990,7 +991,7 @@ var errNoModules = errors.New("not using modules")
990991
// about the requested package and all dependencies and then only reports about the requested package.
991992
// Then we reinvoke it for every dependency. But this is still better than not working at all.
992993
// See golang.org/issue/26504.
993-
func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode, gopath []string) error {
994+
func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode) error {
994995
const debugImportGo = false
995996

996997
// To invoke the go command, we must know the source directory,

0 commit comments

Comments
 (0)