Skip to content

Commit 8bbdb93

Browse files
committed
golangci-lint: enable nilerr linter
cli/command/idresolver/idresolver.go:33:4: error is not nil (line 31) but it returns nil (nilerr) return id, nil ^ cli/command/idresolver/idresolver.go:45:4: error is not nil (line 43) but it returns nil (nilerr) return id, nil ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 7e9d2c7 commit 8bbdb93

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ linters:
1515
- megacheck
1616
- misspell
1717
- nakedret
18+
- nilerr # Detects code that returns nil even if it checks that the error is not nil.
1819
- predeclared
1920
- revive
2021
- staticcheck

cli/command/idresolver/idresolver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func (r *IDResolver) get(ctx context.Context, t interface{}, id string) (string,
3030
case swarm.Node:
3131
node, _, err := r.client.NodeInspectWithRaw(ctx, id)
3232
if err != nil {
33-
return id, nil
33+
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
34+
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.
3435
}
3536
if node.Spec.Annotations.Name != "" {
3637
return node.Spec.Annotations.Name, nil
@@ -42,7 +43,8 @@ func (r *IDResolver) get(ctx context.Context, t interface{}, id string) (string,
4243
case swarm.Service:
4344
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
4445
if err != nil {
45-
return id, nil
46+
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
47+
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.
4648
}
4749
return service.Spec.Annotations.Name, nil
4850
default:

0 commit comments

Comments
 (0)