lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 1c38ee5f authored by Daniel Martí's avatar Daniel Martí

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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
parent 91f3997e
...@@ -237,7 +237,7 @@ func runEnv(cmd *base.Command, args []string) { ...@@ -237,7 +237,7 @@ func runEnv(cmd *base.Command, args []string) {
base.Fatalf("go env -w: arguments must be KEY=VALUE: invalid argument: %s", arg) base.Fatalf("go env -w: arguments must be KEY=VALUE: invalid argument: %s", arg)
} }
key, val := arg[:i], arg[i+1:] key, val := arg[:i], arg[i+1:]
if err := checkEnvWrite(key, val, env); err != nil { if err := checkEnvWrite(key, val); err != nil {
base.Fatalf("go env -w: %v", err) base.Fatalf("go env -w: %v", err)
} }
if _, ok := add[key]; ok { if _, ok := add[key]; ok {
...@@ -259,7 +259,7 @@ func runEnv(cmd *base.Command, args []string) { ...@@ -259,7 +259,7 @@ func runEnv(cmd *base.Command, args []string) {
} }
del := make(map[string]bool) del := make(map[string]bool)
for _, arg := range args { for _, arg := range args {
if err := checkEnvWrite(arg, "", env); err != nil { if err := checkEnvWrite(arg, ""); err != nil {
base.Fatalf("go env -u: %v", err) base.Fatalf("go env -u: %v", err)
} }
del[arg] = true del[arg] = true
...@@ -330,7 +330,7 @@ func printEnvAsJSON(env []cfg.EnvVar) { ...@@ -330,7 +330,7 @@ func printEnvAsJSON(env []cfg.EnvVar) {
} }
} }
func checkEnvWrite(key, val string, env []cfg.EnvVar) error { func checkEnvWrite(key, val string) error {
switch key { switch key {
case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOTOOLDIR": case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOTOOLDIR":
return fmt.Errorf("%s cannot be modified", key) return fmt.Errorf("%s cannot be modified", key)
......
...@@ -593,7 +593,7 @@ func loadImport(pre *preload, path, srcDir string, parent *Package, stk *ImportS ...@@ -593,7 +593,7 @@ func loadImport(pre *preload, path, srcDir string, parent *Package, stk *ImportS
return setErrorPos(perr, importPos) return setErrorPos(perr, importPos)
} }
if mode&ResolveImport != 0 { if mode&ResolveImport != 0 {
if perr := disallowVendor(srcDir, parent, parentPath, path, p, stk); perr != p { if perr := disallowVendor(srcDir, path, p, stk); perr != p {
return setErrorPos(perr, importPos) return setErrorPos(perr, importPos)
} }
} }
...@@ -1321,11 +1321,10 @@ func findInternal(path string) (index int, ok bool) { ...@@ -1321,11 +1321,10 @@ func findInternal(path string) (index int, ok bool) {
return 0, false return 0, false
} }
// disallowVendor checks that srcDir (containing package importerPath, if non-empty) // disallowVendor checks that srcDir is allowed to import p as path.
// is allowed to import p as path.
// If the import is allowed, disallowVendor returns the original package p. // If the import is allowed, disallowVendor returns the original package p.
// If not, it returns a new package containing just an appropriate error. // If not, it returns a new package containing just an appropriate error.
func disallowVendor(srcDir string, importer *Package, importerPath, path string, p *Package, stk *ImportStack) *Package { func disallowVendor(srcDir string, path string, p *Package, stk *ImportStack) *Package {
// The stack includes p.ImportPath. // The stack includes p.ImportPath.
// If that's the only thing on the stack, we started // If that's the only thing on the stack, we started
// with a name given on the command line, not an // with a name given on the command line, not an
......
...@@ -80,17 +80,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -80,17 +80,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
escPath, escVers := mod[:i], mod[i+1:] escPath, escVers := mod[:i], mod[i+1:]
path, err := module.UnescapePath(escPath) path, err := module.UnescapePath(escPath)
if err != nil { if err != nil {
reportError(w, r, err) reportError(w, err)
return return
} }
vers, err := module.UnescapeVersion(escVers) vers, err := module.UnescapeVersion(escVers)
if err != nil { if err != nil {
reportError(w, r, err) reportError(w, err)
return return
} }
id, err := s.ops.Lookup(ctx, module.Version{Path: path, Version: vers}) id, err := s.ops.Lookup(ctx, module.Version{Path: path, Version: vers})
if err != nil { if err != nil {
reportError(w, r, err) reportError(w, err)
return return
} }
records, err := s.ops.ReadRecords(ctx, id, 1) records, err := s.ops.ReadRecords(ctx, id, 1)
...@@ -137,7 +137,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -137,7 +137,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
start := t.N << uint(t.H) start := t.N << uint(t.H)
records, err := s.ops.ReadRecords(ctx, start, int64(t.W)) records, err := s.ops.ReadRecords(ctx, start, int64(t.W))
if err != nil { if err != nil {
reportError(w, r, err) reportError(w, err)
return return
} }
if len(records) != t.W { if len(records) != t.W {
...@@ -159,7 +159,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -159,7 +159,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
data, err := s.ops.ReadTileData(ctx, t) data, err := s.ops.ReadTileData(ctx, t)
if err != nil { if err != nil {
reportError(w, r, err) reportError(w, err)
return return
} }
w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Type", "application/octet-stream")
...@@ -172,7 +172,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -172,7 +172,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Otherwise it is an internal server error. // Otherwise it is an internal server error.
// The caller must only call reportError in contexts where // The caller must only call reportError in contexts where
// a not-found err should be reported as 404. // a not-found err should be reported as 404.
func reportError(w http.ResponseWriter, r *http.Request, err error) { func reportError(w http.ResponseWriter, err error) {
if os.IsNotExist(err) { if os.IsNotExist(err) {
http.Error(w, err.Error(), http.StatusNotFound) http.Error(w, err.Error(), http.StatusNotFound)
return return
......
...@@ -15,7 +15,6 @@ import ( ...@@ -15,7 +15,6 @@ import (
"cmd/go/internal/base" "cmd/go/internal/base"
"cmd/go/internal/cache" "cmd/go/internal/cache"
"cmd/go/internal/cfg" "cmd/go/internal/cfg"
"cmd/go/internal/load"
"cmd/go/internal/str" "cmd/go/internal/str"
"cmd/internal/buildid" "cmd/internal/buildid"
) )
...@@ -421,7 +420,7 @@ func (b *Builder) fileHash(file string) string { ...@@ -421,7 +420,7 @@ func (b *Builder) fileHash(file string) string {
// during a's work. The caller should defer b.flushOutput(a), to make sure // during a's work. The caller should defer b.flushOutput(a), to make sure
// that flushOutput is eventually called regardless of whether the action // that flushOutput is eventually called regardless of whether the action
// succeeds. The flushOutput call must happen after updateBuildID. // succeeds. The flushOutput call must happen after updateBuildID.
func (b *Builder) useCache(a *Action, p *load.Package, actionHash cache.ActionID, target string) bool { func (b *Builder) useCache(a *Action, actionHash cache.ActionID, target string) bool {
// The second half of the build ID here is a placeholder for the content hash. // The second half of the build ID here is a placeholder for the content hash.
// It's important that the overall buildID be unlikely verging on impossible // It's important that the overall buildID be unlikely verging on impossible
// to appear in the output by chance, but that should be taken care of by // to appear in the output by chance, but that should be taken care of by
......
...@@ -395,7 +395,7 @@ func (b *Builder) build(a *Action) (err error) { ...@@ -395,7 +395,7 @@ func (b *Builder) build(a *Action) (err error) {
bit(needCompiledGoFiles, b.NeedCompiledGoFiles) bit(needCompiledGoFiles, b.NeedCompiledGoFiles)
if !p.BinaryOnly { if !p.BinaryOnly {
if b.useCache(a, p, b.buildActionID(a), p.Target) { if b.useCache(a, b.buildActionID(a), p.Target) {
// We found the main output in the cache. // We found the main output in the cache.
// If we don't need any other outputs, we can stop. // If we don't need any other outputs, we can stop.
// Otherwise, we need to write files to a.Objdir (needVet, needCgoHdr). // 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) { ...@@ -1171,7 +1171,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
// link is the action for linking a single command. // link is the action for linking a single command.
// Note that any new influence on this logic must be reported in b.linkActionID above as well. // Note that any new influence on this logic must be reported in b.linkActionID above as well.
func (b *Builder) link(a *Action) (err error) { func (b *Builder) link(a *Action) (err error) {
if b.useCache(a, a.Package, b.linkActionID(a), a.Package.Target) || b.IsCmdList { if b.useCache(a, b.linkActionID(a), a.Package.Target) || b.IsCmdList {
return nil return nil
} }
defer b.flushOutput(a) defer b.flushOutput(a)
...@@ -1404,7 +1404,7 @@ func (b *Builder) linkSharedActionID(a *Action) cache.ActionID { ...@@ -1404,7 +1404,7 @@ func (b *Builder) linkSharedActionID(a *Action) cache.ActionID {
} }
func (b *Builder) linkShared(a *Action) (err error) { func (b *Builder) linkShared(a *Action) (err error) {
if b.useCache(a, nil, b.linkSharedActionID(a), a.Target) || b.IsCmdList { if b.useCache(a, b.linkSharedActionID(a), a.Target) || b.IsCmdList {
return nil return nil
} }
defer b.flushOutput(a) defer b.flushOutput(a)
......
...@@ -592,13 +592,14 @@ func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Packa ...@@ -592,13 +592,14 @@ func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Packa
return p, fmt.Errorf("import %q: cannot import absolute path", path) return p, fmt.Errorf("import %q: cannot import absolute path", path)
} }
gopath := ctxt.gopath() // needed by both importGo and below; avoid computing twice if err := ctxt.importGo(p, path, srcDir, mode); err == nil {
if err := ctxt.importGo(p, path, srcDir, mode, gopath); err == nil {
goto Found goto Found
} else if err != errNoModules { } else if err != errNoModules {
return p, err return p, err
} }
gopath := ctxt.gopath() // needed twice below; avoid computing many times
// tried records the location of unsuccessful package lookups // tried records the location of unsuccessful package lookups
var tried struct { var tried struct {
vendor []string vendor []string
...@@ -990,7 +991,7 @@ var errNoModules = errors.New("not using modules") ...@@ -990,7 +991,7 @@ var errNoModules = errors.New("not using modules")
// about the requested package and all dependencies and then only reports about the requested package. // about the requested package and all dependencies and then only reports about the requested package.
// Then we reinvoke it for every dependency. But this is still better than not working at all. // Then we reinvoke it for every dependency. But this is still better than not working at all.
// See golang.org/issue/26504. // See golang.org/issue/26504.
func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode, gopath []string) error { func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode) error {
const debugImportGo = false const debugImportGo = false
// To invoke the go command, we must know the source directory, // To invoke the go command, we must know the source directory,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment