From 3f0c189e48c39ec7caed8d2cd00900000920e9dd Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 20 Nov 2023 14:26:41 +0100 Subject: [PATCH] linting: address slice-append issues found by gocritic cli/command/trust/inspect.go:74:33: appendAssign: append result not assigned to the same slice (gocritic) signatureRows[idx].Signers = append(sig.Signers, releasedRoleName) ^ cli/command/task/print.go:92:7: appendAssign: append result not assigned to the same slice (gocritic) t := append(tasks[:0:0], tasks...) ^ Signed-off-by: Sebastiaan van Stijn --- cli/command/task/print.go | 3 ++- cli/command/trust/inspect.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/command/task/print.go b/cli/command/task/print.go index da9645b72c..4c9b362a2f 100644 --- a/cli/command/task/print.go +++ b/cli/command/task/print.go @@ -89,7 +89,8 @@ func Print(ctx context.Context, dockerCli command.Cli, tasks []swarm.Task, resol // Task-names are not unique in cases where "tasks" contains previous/rotated tasks. func generateTaskNames(ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver) ([]swarm.Task, error) { // Use a copy of the tasks list, to not modify the original slice - t := append(tasks[:0:0], tasks...) + // see https://github.com/go101/go101/wiki/How-to-efficiently-clone-a-slice%3F + t := append(tasks[:0:0], tasks...) //nolint:gocritic // ignore appendAssign: append result not assigned to the same slice for i, task := range t { serviceName, err := resolver.Resolve(ctx, swarm.Service{}, task.ServiceID) diff --git a/cli/command/trust/inspect.go b/cli/command/trust/inspect.go index d7370bd09d..980fb321c4 100644 --- a/cli/command/trust/inspect.go +++ b/cli/command/trust/inspect.go @@ -71,7 +71,7 @@ func getRepoTrustInfo(cli command.Cli, remote string) ([]byte, error) { // process the signatures to include repo admin if signed by the base targets role for idx, sig := range signatureRows { if len(sig.Signers) == 0 { - signatureRows[idx].Signers = append(sig.Signers, releasedRoleName) + signatureRows[idx].Signers = []string{releasedRoleName} } }