diff --git a/distbuild/pkg/api/heartbeat_handler.go b/distbuild/pkg/api/heartbeat_handler.go index 6c7629b..c335a54 100644 --- a/distbuild/pkg/api/heartbeat_handler.go +++ b/distbuild/pkg/api/heartbeat_handler.go @@ -29,7 +29,7 @@ func (h *HeartbeatHandler) doHeartbeat(w http.ResponseWriter, r *http.Request) e } var req HeartbeatRequest - if err := json.Unmarshal(reqJSON, &req); err != nil { + if err = json.Unmarshal(reqJSON, &req); err != nil { return err } diff --git a/distbuild/pkg/artifact/cache_test.go b/distbuild/pkg/artifact/cache_test.go index faf88c4..b4a3801 100644 --- a/distbuild/pkg/artifact/cache_test.go +++ b/distbuild/pkg/artifact/cache_test.go @@ -18,8 +18,8 @@ type testCache struct { tmpDir string } -func (c *testCache) cleanup() error { - return os.RemoveAll(c.tmpDir) +func (c *testCache) cleanup() { + _ = os.RemoveAll(c.tmpDir) } func newTestCache(t *testing.T) *testCache { diff --git a/distbuild/pkg/artifact/client.go b/distbuild/pkg/artifact/client.go index c26be3e..4ad79e7 100644 --- a/distbuild/pkg/artifact/client.go +++ b/distbuild/pkg/artifact/client.go @@ -16,7 +16,7 @@ func Download(ctx context.Context, endpoint string, c *Cache, artifactID build.I if err != nil { return err } - defer abort() + defer func() { _ = abort() }() req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint+"/artifact?id="+artifactID.String(), nil) if err != nil { diff --git a/distbuild/pkg/client/build.go b/distbuild/pkg/client/build.go index 7979c06..92943a7 100644 --- a/distbuild/pkg/client/build.go +++ b/distbuild/pkg/client/build.go @@ -66,7 +66,7 @@ func (c *Client) Build(ctx context.Context, graph build.Graph, lsn BuildListener } c.l.Debug("build started", zap.String("build_id", started.ID.String())) - if err := c.uploadSources(ctx, &graph, started); err != nil { + if err = c.uploadSources(ctx, &graph, started); err != nil { return err } diff --git a/distbuild/pkg/filecache/client.go b/distbuild/pkg/filecache/client.go index f422919..3e82e97 100644 --- a/distbuild/pkg/filecache/client.go +++ b/distbuild/pkg/filecache/client.go @@ -56,7 +56,7 @@ func (c *Client) Download(ctx context.Context, localCache *Cache, id build.ID) e if err != nil { return err } - defer abort() + defer func() { _ = abort() }() req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint+"/file?id="+id.String(), nil) if err != nil { diff --git a/distbuild/pkg/filecache/client_test.go b/distbuild/pkg/filecache/client_test.go index a0d852a..79c13c4 100644 --- a/distbuild/pkg/filecache/client_test.go +++ b/distbuild/pkg/filecache/client_test.go @@ -31,7 +31,7 @@ func newEnv(t *testing.T) *env { cache := newCache(t) defer func() { if cache != nil { - _ = cache.cleanup() + cache.cleanup() } }() @@ -54,7 +54,7 @@ func newEnv(t *testing.T) *env { func (e *env) stop() { e.server.Close() - _ = e.cache.cleanup() + e.cache.cleanup() } func TestFileUpload(t *testing.T) { @@ -99,11 +99,11 @@ func TestFileUpload(t *testing.T) { var wg sync.WaitGroup wg.Add(G) + id := build.ID{0x03, byte(i)} for j := 0; j < G; j++ { go func() { defer wg.Done() - id := build.ID{0x03, byte(j)} assert.NoError(t, env.client.Upload(ctx, id, tmpFilePath)) }() } @@ -124,7 +124,7 @@ func TestFileDownload(t *testing.T) { w, abort, err := env.cache.Write(id) require.NoError(t, err) - defer abort() + defer func() { _ = abort() }() _, err = w.Write([]byte("foobar")) require.NoError(t, err) diff --git a/distbuild/pkg/filecache/filecache_test.go b/distbuild/pkg/filecache/filecache_test.go index 6575b04..1d0d8a7 100644 --- a/distbuild/pkg/filecache/filecache_test.go +++ b/distbuild/pkg/filecache/filecache_test.go @@ -27,8 +27,8 @@ func newCache(t *testing.T) *testCache { return &testCache{Cache: c, tmpDir: tmpDir} } -func (c *testCache) cleanup() error { - return os.Remove(c.tmpDir) +func (c *testCache) cleanup() { + _ = os.Remove(c.tmpDir) } func TestFileCache(t *testing.T) { diff --git a/distbuild/pkg/filecache/handler.go b/distbuild/pkg/filecache/handler.go index a829350..ddd21c2 100644 --- a/distbuild/pkg/filecache/handler.go +++ b/distbuild/pkg/filecache/handler.go @@ -59,7 +59,7 @@ func (h *Handler) doPut(w http.ResponseWriter, r *http.Request, id build.ID) err } else if err != nil { return nil, err } - defer abort() + defer func() { _ = abort() }() if _, err = io.Copy(w, r.Body); err != nil { return nil, err diff --git a/distbuild/pkg/worker/download.go b/distbuild/pkg/worker/download.go index 2c2c4d6..aaa73b2 100644 --- a/distbuild/pkg/worker/download.go +++ b/distbuild/pkg/worker/download.go @@ -12,7 +12,7 @@ func (w *Worker) pullFiles(ctx context.Context, files map[build.ID]string) error for id := range files { _, unlock, err := w.fileCache.Get(id) if errors.Is(err, filecache.ErrNotFound) { - if err := w.fileClient.Download(ctx, w.fileCache, id); err != nil { + if err = w.fileClient.Download(ctx, w.fileCache, id); err != nil { return err } } else if err != nil { diff --git a/distbuild/pkg/worker/job.go b/distbuild/pkg/worker/job.go index 631b546..8c2334c 100644 --- a/distbuild/pkg/worker/job.go +++ b/distbuild/pkg/worker/job.go @@ -165,7 +165,7 @@ func (w *Worker) runJob(ctx context.Context, spec *api.JobSpec) (*api.JobResult, return res, nil } - if err := w.pullFiles(ctx, spec.SourceFiles); err != nil { + if err = w.pullFiles(ctx, spec.SourceFiles); err != nil { return nil, err }