From 7af268045fefa762b4a05bc82d63f1d7b1467e2e Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Sun, 15 Dec 2024 08:54:40 +0400 Subject: [PATCH] cmd/go/internal: remove unused result parameter Incomplete Put operation already returns an error. --- src/cmd/go/internal/cache/cache.go | 22 +++++++++++----------- src/cmd/go/internal/cache/prog.go | 16 ++++++++-------- src/cmd/go/internal/list/list.go | 2 +- src/cmd/go/internal/work/action.go | 2 +- src/cmd/go/internal/work/buildid.go | 4 ++-- src/cmd/go/internal/work/exec.go | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/cmd/go/internal/cache/cache.go b/src/cmd/go/internal/cache/cache.go index e717503707f17d..5fcccfaaaa7c65 100644 --- a/src/cmd/go/internal/cache/cache.go +++ b/src/cmd/go/internal/cache/cache.go @@ -50,9 +50,9 @@ type Cache interface { // As a special case, if the ReadSeeker is of type noVerifyReadSeeker, // the verification from GODEBUG=goverifycache=1 is skipped. // - // After a success call to Get, OutputFile(Entry.OutputID) must + // After a success call to Put, OutputFile(Entry.OutputID) must // exist on disk for until Close is called (at the end of the process). - Put(ActionID, io.ReadSeeker) (_ OutputID, size int64, _ error) + Put(ActionID, io.ReadSeeker) (OutputID, error) // Close is called at the end of the go process. Implementations can do // cache cleanup work at this phase, or wait for and report any errors from @@ -504,7 +504,7 @@ type noVerifyReadSeeker struct { // Put stores the given output in the cache as the output for the action ID. // It may read file twice. The content of file must not change between the two passes. -func (c *DiskCache) Put(id ActionID, file io.ReadSeeker) (OutputID, int64, error) { +func (c *DiskCache) Put(id ActionID, file io.ReadSeeker) (OutputID, error) { wrapper, isNoVerify := file.(noVerifyReadSeeker) if isNoVerify { file = wrapper.ReadSeeker @@ -515,7 +515,7 @@ func (c *DiskCache) Put(id ActionID, file io.ReadSeeker) (OutputID, int64, error // PutExecutable is used to store the output as the output for the action ID into a // file with the given base name, with the executable mode bit set. // It may read file twice. The content of file must not change between the two passes. -func (c *DiskCache) PutExecutable(id ActionID, name string, file io.ReadSeeker) (OutputID, int64, error) { +func (c *DiskCache) PutExecutable(id ActionID, name string, file io.ReadSeeker) (OutputID, error) { if name == "" { panic("PutExecutable called without a name") } @@ -530,19 +530,19 @@ func (c *DiskCache) PutExecutable(id ActionID, name string, file io.ReadSeeker) // when GODEBUG=goverifycache=1 is set. // It is meant for data that is OK to cache but that we expect to vary slightly from run to run, // like test output containing times and the like. -func PutNoVerify(c Cache, id ActionID, file io.ReadSeeker) (OutputID, int64, error) { +func PutNoVerify(c Cache, id ActionID, file io.ReadSeeker) (OutputID, error) { return c.Put(id, noVerifyReadSeeker{file}) } -func (c *DiskCache) put(id ActionID, executableName string, file io.ReadSeeker, allowVerify bool) (OutputID, int64, error) { +func (c *DiskCache) put(id ActionID, executableName string, file io.ReadSeeker, allowVerify bool) (OutputID, error) { // Compute output ID. h := sha256.New() if _, err := file.Seek(0, 0); err != nil { - return OutputID{}, 0, err + return OutputID{}, err } size, err := io.Copy(h, file) if err != nil { - return OutputID{}, 0, err + return OutputID{}, err } var out OutputID h.Sum(out[:0]) @@ -553,16 +553,16 @@ func (c *DiskCache) put(id ActionID, executableName string, file io.ReadSeeker, fileMode = 0o777 } if err := c.copyFile(file, executableName, out, size, fileMode); err != nil { - return out, size, err + return out, err } // Add to cache index. - return out, size, c.putIndexEntry(id, out, size, allowVerify) + return out, c.putIndexEntry(id, out, size, allowVerify) } // PutBytes stores the given bytes in the cache as the output for the action ID. func PutBytes(c Cache, id ActionID, data []byte) error { - _, _, err := c.Put(id, bytes.NewReader(data)) + _, err := c.Put(id, bytes.NewReader(data)) return err } diff --git a/src/cmd/go/internal/cache/prog.go b/src/cmd/go/internal/cache/prog.go index e09620bac86c48..3ce088176dddd7 100644 --- a/src/cmd/go/internal/cache/prog.go +++ b/src/cmd/go/internal/cache/prog.go @@ -378,26 +378,26 @@ func (c *ProgCache) OutputFile(o OutputID) string { return c.outputFile[o] } -func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (_ OutputID, size int64, _ error) { +func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (OutputID, error) { // Compute output ID. h := sha256.New() if _, err := file.Seek(0, 0); err != nil { - return OutputID{}, 0, err + return OutputID{}, err } size, err := io.Copy(h, file) if err != nil { - return OutputID{}, 0, err + return OutputID{}, err } var out OutputID h.Sum(out[:0]) if _, err := file.Seek(0, 0); err != nil { - return OutputID{}, 0, err + return OutputID{}, err } if !c.can[cmdPut] { // Child is a read-only cache. Do nothing. - return out, size, nil + return out, nil } // For compatibility with Go 1.23/1.24 GOEXPERIMENT=gocacheprog users, also @@ -416,13 +416,13 @@ func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (_ OutputID, size int64, BodySize: size, }) if err != nil { - return OutputID{}, 0, err + return OutputID{}, err } if res.DiskPath == "" { - return OutputID{}, 0, errors.New("GOCACHEPROG didn't return DiskPath in put response") + return OutputID{}, errors.New("GOCACHEPROG didn't return DiskPath in put response") } c.noteOutputFile(out, res.DiskPath) - return out, size, err + return out, err } func (c *ProgCache) Close() error { diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index 04fdadef3fde69..f77f5a92bf409c 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -673,7 +673,7 @@ func runList(ctx context.Context, cmd *base.Command, args []string) { h := cache.NewHash("testmain") h.Write([]byte("testmain\n")) h.Write(data) - out, _, err := c.Put(h.Sum(), bytes.NewReader(data)) + out, err := c.Put(h.Sum(), bytes.NewReader(data)) if err != nil { base.Fatalf("%s", err) } diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go index 44bb9f8c1e4a05..51c0448e2b90b3 100644 --- a/src/cmd/go/internal/work/action.go +++ b/src/cmd/go/internal/work/action.go @@ -516,7 +516,7 @@ func (p *pgoActor) Act(b *Builder, ctx context.Context, a *Action) error { } c := cache.Default() - outputID, _, err := c.Put(a.actionID, r) + outputID, err := c.Put(a.actionID, r) r.Close() if err != nil { return fmt.Errorf("error adding target to cache: %w", err) diff --git a/src/cmd/go/internal/work/buildid.go b/src/cmd/go/internal/work/buildid.go index ca3dce2df47a48..015f661d9a9823 100644 --- a/src/cmd/go/internal/work/buildid.go +++ b/src/cmd/go/internal/work/buildid.go @@ -746,7 +746,7 @@ func (b *Builder) updateBuildID(a *Action, target string) error { if a.output == nil { panic("internal error: a.output not set") } - outputID, _, err := c.Put(a.actionID, r) + outputID, err := c.Put(a.actionID, r) r.Close() if err == nil && cfg.BuildX { sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList("cp", target, c.OutputFile(outputID)))) @@ -770,7 +770,7 @@ func (b *Builder) updateBuildID(a *Action, target string) error { if name == "" { name = path.Base(a.Package.ImportPath) } - outputID, _, err := c.PutExecutable(a.actionID, name+cfg.ExeSuffix, r) + outputID, err := c.PutExecutable(a.actionID, name+cfg.ExeSuffix, r) r.Close() if err == nil && cfg.BuildX { sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList("cp", target, c.OutputFile(outputID)))) diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 2538fae52f2d8e..3ab3b0641a6ae7 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -1028,7 +1028,7 @@ func (b *Builder) cacheObjdirFile(a *Action, c cache.Cache, name string) error { return err } defer f.Close() - _, _, err = c.Put(cache.Subkey(a.actionID, name), f) + _, err = c.Put(cache.Subkey(a.actionID, name), f) return err }