Skip to content

Commit 51e122c

Browse files
authored
chore: add support for gci, gofmt, gofumpt, goimports and whitespace (#2176)
1 parent 1aae88e commit 51e122c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+134
-139
lines changed

.github/workflows/golangci-lint.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: golangci-lint
2+
on:
3+
merge_group:
4+
pull_request:
5+
permissions:
6+
contents: read
7+
checks: write
8+
pull-requests: read
9+
jobs:
10+
golangci:
11+
name: lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: golangci-lint
16+
uses: golangci/golangci-lint-action@v6
17+
with:
18+
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
19+
version: latest
20+
args: --timeout 5m

.golangci.yml

+14-20
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,22 @@ linters:
88

99
# Run golangci-lint linters to see
1010
enable:
11-
- deadcode
12-
- errcheck
13-
- gosimple
14-
- govet
15-
- ineffassign
16-
- staticcheck
17-
- structcheck
18-
- typecheck
19-
- unused
20-
- varcheck
21-
- goconst
22-
- goimports
23-
- golint
24-
- misspell
25-
- stylecheck
26-
- unconvert
27-
- unparam
28-
- whitespace
29-
- gosec
30-
# - wsl Could be interesting but need a lot of changes
11+
- asasalint # check for pass []any as any in variadic func(...any) [fast: false, auto-fix: false]
12+
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
13+
- bidichk # Checks for dangerous unicode character sequences [fast: true, auto-fix: false]
14+
- decorder # check declaration order and count of types, constants, variables and functions [fast: true, auto-fix: false]
15+
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
16+
- dupword # checks for duplicate words in the source code [fast: true, auto-fix: true]
17+
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
18+
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
19+
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
20+
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
21+
- whitespace # Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
3122

3223
issues:
24+
max-issues-per-linter: 0
25+
max-same-issues: 0
26+
3327
exclude-rules:
3428
- path: _test\.go
3529
linters:

api/applesilicon/v1alpha1/apple_silicon_utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption
4444
ServerID: req.ServerID,
4545
Zone: req.Zone,
4646
}, opts...)
47-
4847
if err != nil {
4948
return nil, false, err
5049
}

api/block/v1alpha1/snapshot_utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func (s *API) WaitForSnapshot(req *WaitForSnapshotRequest, opts ...scw.RequestOp
4141
SnapshotID: req.SnapshotID,
4242
Zone: req.Zone,
4343
}, opts...)
44-
4544
if err != nil {
4645
return nil, false, err
4746
}

api/block/v1alpha1/volume_utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func (s *API) WaitForVolume(req *WaitForVolumeRequest, opts ...scw.RequestOption
5656
VolumeID: req.VolumeID,
5757
Zone: req.Zone,
5858
}, opts...)
59-
6059
if err != nil {
6160
return nil, false, err
6261
}

api/cockpit/v1beta1/cockpit_utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (s *API) WaitForCockpit(
5454
Timeout: timeout,
5555
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
5656
})
57-
5857
if err != nil {
5958
return nil, errors.Wrap(err, "waiting for Cockpit failed")
6059
}

api/dedibox/v1/dedibox_utils.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package dedibox
22

33
import (
4+
"time"
5+
46
"github.com/scaleway/scaleway-sdk-go/internal/async"
57
"github.com/scaleway/scaleway-sdk-go/internal/errors"
68
"github.com/scaleway/scaleway-sdk-go/scw"
7-
"time"
89
)
910

1011
const (

api/documentdb/v1beta1/documentdb_utils.go

-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func (s *API) WaitForInstance(req *WaitForInstanceRequest, opts ...scw.RequestOp
4545
InstanceID: req.InstanceID,
4646
Region: req.Region,
4747
}, opts...)
48-
4948
if err != nil {
5049
return nil, false, err
5150
}
@@ -91,7 +90,6 @@ func (s *API) WaitForInstanceLog(req *WaitForInstanceLogRequest, opts ...scw.Req
9190
res, err := s.GetInstanceLog(&GetInstanceLogRequest{
9291
Region: req.Region,
9392
}, opts...)
94-
9593
if err != nil {
9694
return nil, false, err
9795
}
@@ -139,7 +137,6 @@ func (s *API) WaitForReadReplica(req *WaitForReadReplicaRequest, opts ...scw.Req
139137
ReadReplicaID: req.ReadReplicaID,
140138
Region: req.Region,
141139
}, opts...)
142-
143140
if err != nil {
144141
return nil, false, err
145142
}

api/domain/v2beta1/domain_utils.go

-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func (s *API) WaitForDNSZone(
3434
req *WaitForDNSZoneRequest,
3535
opts ...scw.RequestOption,
3636
) (*DNSZone, error) {
37-
3837
timeout := defaultTimeout
3938
if req.Timeout != nil {
4039
timeout = *req.Timeout
@@ -62,7 +61,6 @@ func (s *API) WaitForDNSZone(
6261

6362
// listing dns zones and take the first one
6463
DNSZones, err := s.ListDNSZones(listReq, opts...)
65-
6664
if err != nil {
6765
return nil, false, err
6866
}
@@ -80,7 +78,6 @@ func (s *API) WaitForDNSZone(
8078
Timeout: timeout,
8179
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
8280
})
83-
8481
if err != nil {
8582
return nil, errors.Wrap(err, "waiting for DNS failed")
8683
}
@@ -118,7 +115,6 @@ func (s *API) WaitForDNSRecordExist(
118115
Type: req.RecordType,
119116
DNSZone: req.DNSZone,
120117
}, opts...)
121-
122118
if err != nil {
123119
return nil, false, err
124120
}
@@ -134,7 +130,6 @@ func (s *API) WaitForDNSRecordExist(
134130
Timeout: timeout,
135131
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
136132
})
137-
138133
if err != nil {
139134
return nil, errors.Wrap(err, "check for DNS Record exist failed")
140135
}

api/inference/v1beta1/inference_utils.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package inference
22

33
import (
4+
"time"
5+
46
"github.com/scaleway/scaleway-sdk-go/internal/async"
57
"github.com/scaleway/scaleway-sdk-go/internal/errors"
68
"github.com/scaleway/scaleway-sdk-go/scw"
7-
"time"
89
)
910

1011
const (

api/instance/v1/image_utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func (s *API) WaitForImage(req *WaitForImageRequest, opts ...scw.RequestOption)
3838
ImageID: req.ImageID,
3939
Zone: req.Zone,
4040
}, opts...)
41-
4241
if err != nil {
4342
return nil, false, err
4443
}

api/instance/v1/instance_metadata_sdk.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import (
1313
"github.com/scaleway/scaleway-sdk-go/internal/errors"
1414
)
1515

16-
var (
17-
metadataRetryBindPort = 200
18-
)
16+
var metadataRetryBindPort = 200
1917

20-
const metadataAPIv4 = "http://169.254.42.42"
21-
const metadataAPIv6 = "http://[fd00:42::42]"
18+
const (
19+
metadataAPIv4 = "http://169.254.42.42"
20+
metadataAPIv6 = "http://[fd00:42::42]"
21+
)
2222

2323
// MetadataAPI metadata API
2424
type MetadataAPI struct {
@@ -82,7 +82,7 @@ type Metadata struct {
8282
Organization string `json:"organization,omitempty"`
8383
Project string `json:"project,omitempty"`
8484
CommercialType string `json:"commercial_type,omitempty"`
85-
//PublicIP IPv4 only
85+
// PublicIP IPv4 only
8686
PublicIP struct {
8787
ID string `json:"id"`
8888
Address string `json:"address"`

api/instance/v1/instance_sdk_server_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ func TestCreateServerWithIncorrectBody(t *testing.T) {
153153

154154
instanceAPI := NewAPI(client)
155155

156-
var (
157-
zone = scw.ZoneFrPar1
158-
)
156+
zone := scw.ZoneFrPar1
159157

160158
// Create server
161159
_, err = instanceAPI.CreateServer(&CreateServerRequest{

api/instance/v1/instance_utils.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ import (
77
"time"
88

99
"github.com/scaleway/scaleway-sdk-go/internal/async"
10-
1110
"github.com/scaleway/scaleway-sdk-go/internal/errors"
1211
"github.com/scaleway/scaleway-sdk-go/scw"
1312
)
1413

15-
var (
16-
resourceLock sync.Map
17-
)
14+
var resourceLock sync.Map
1815

1916
// lockResource locks a resource from a specific resourceID
2017
func lockResource(resourceID string) *sync.Mutex {
@@ -315,7 +312,6 @@ func (s *API) WaitForPrivateNIC(req *WaitForPrivateNICRequest, opts ...scw.Reque
315312
Zone: req.Zone,
316313
PrivateNicID: req.PrivateNicID,
317314
}, opts...)
318-
319315
if err != nil {
320316
return nil, false, err
321317
}

api/instance/v1/server_utils.go

-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption
7979
ServerID: req.ServerID,
8080
Zone: req.Zone,
8181
}, opts...)
82-
8382
if err != nil {
8483
return nil, false, err
8584
}
@@ -168,7 +167,6 @@ func (s *API) GetServerType(req *GetServerTypeRequest) (*ServerType, error) {
168167
res, err := s.ListServersTypes(&ListServersTypesRequest{
169168
Zone: req.Zone,
170169
}, scw.WithAllPages())
171-
172170
if err != nil {
173171
return nil, err
174172
}

api/instance/v1/snapshot_utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func (s *API) WaitForSnapshot(req *WaitForSnapshotRequest, opts ...scw.RequestOp
3838
SnapshotID: req.SnapshotID,
3939
Zone: req.Zone,
4040
}, opts...)
41-
4241
if err != nil {
4342
return nil, false, err
4443
}

api/instance/v1/snapshot_utils_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ func TestAPI_UpdateSnapshot(t *testing.T) {
7575

7676
instanceAPI := NewAPI(client)
7777

78-
var (
79-
volumeSize = 1 * scw.GB
80-
)
78+
volumeSize := 1 * scw.GB
8179

8280
createVolume, err := instanceAPI.CreateVolume(&CreateVolumeRequest{
8381
Name: "volume_name",

api/instance/v1/volume_utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func (s *API) WaitForVolume(req *WaitForVolumeRequest, opts ...scw.RequestOption
4040
VolumeID: req.VolumeID,
4141
Zone: req.Zone,
4242
}, opts...)
43-
4443
if err != nil {
4544
return nil, false, err
4645
}

api/jobs/v1alpha1/custom_job_run.go

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ func (s *API) WaitForJobRun(req *WaitForJobRunRequest, opts ...scw.RequestOption
4444
JobRunID: req.JobRunID,
4545
Region: req.Region,
4646
}, opts...)
47-
4847
if err != nil {
4948
return nil, false, err
5049
}

api/k8s/v1/k8s_helpers.go

-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func (s *API) WaitForPool(req *WaitForPoolRequest, opts ...scw.RequestOption) (*
9595
PoolID: req.PoolID,
9696
Region: req.Region,
9797
}, opts...)
98-
9998
if err != nil {
10099
return nil, false, err
101100
}
@@ -143,7 +142,6 @@ func (s *API) WaitForNode(req *WaitForNodeRequest, opts ...scw.RequestOption) (*
143142
NodeID: req.NodeID,
144143
Region: req.Region,
145144
}, opts...)
146-
147145
if err != nil {
148146
return nil, false, err
149147
}

api/lb/v1/lb_utils.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ func waitForLb(timeout *time.Duration, retryInterval *time.Duration, getLB func(
7171
lb, err := async.WaitSync(&async.WaitSyncConfig{
7272
Get: func() (interface{}, bool, error) {
7373
res, err := getLB()
74-
7574
if err != nil {
7675
return nil, false, err
7776
}
@@ -189,7 +188,7 @@ func waitForPNLb(timeout *time.Duration, retryInterval *time.Duration, getPNs fu
189188
if err != nil {
190189
return nil, false, err
191190
}
192-
//wait at the first not terminal state
191+
// wait at the first not terminal state
193192
_, isTerminal := terminalStatus[pn.Status]
194193
if !isTerminal {
195194
return pns, isTerminal, nil
@@ -259,7 +258,6 @@ func waitForLBCertificate(timeout *time.Duration, retryInterval *time.Duration,
259258
crt, err := async.WaitSync(&async.WaitSyncConfig{
260259
Get: func() (interface{}, bool, error) {
261260
res, err := getCertificate()
262-
263261
if err != nil {
264262
return nil, false, err
265263
}

api/marketplace/v2/marketplace_utils_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ func TestGetImageByLabel(t *testing.T) {
5555
ImageLabel: "foo-bar-image",
5656
})
5757
testhelpers.Assert(t, err != nil, "Should have error")
58-
//testhelpers.Equals(t, "scaleway-sdk-go: couldn't find a matching image for the given label (foo-bar-image)", err.Error())
58+
// testhelpers.Equals(t, "scaleway-sdk-go: couldn't find a matching image for the given label (foo-bar-image)", err.Error())
5959
})
6060
}

api/rdb/v1/rdb_utils.go

-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func (s *API) WaitForInstance(req *WaitForInstanceRequest, opts ...scw.RequestOp
4545
InstanceID: req.InstanceID,
4646
Region: req.Region,
4747
}, opts...)
48-
4948
if err != nil {
5049
return nil, false, err
5150
}
@@ -92,7 +91,6 @@ func (s *API) WaitForDatabaseBackup(req *WaitForDatabaseBackupRequest, opts ...s
9291
DatabaseBackupID: req.DatabaseBackupID,
9392
Region: req.Region,
9493
}, opts...)
95-
9694
if err != nil {
9795
return nil, false, err
9896
}
@@ -139,7 +137,6 @@ func (s *API) WaitForInstanceLog(req *WaitForInstanceLogRequest, opts ...scw.Req
139137
Region: req.Region,
140138
InstanceLogID: req.InstanceLogID,
141139
}, opts...)
142-
143140
if err != nil {
144141
return nil, false, err
145142
}
@@ -187,7 +184,6 @@ func (s *API) WaitForReadReplica(req *WaitForReadReplicaRequest, opts ...scw.Req
187184
ReadReplicaID: req.ReadReplicaID,
188185
Region: req.Region,
189186
}, opts...)
190-
191187
if err != nil {
192188
return nil, false, err
193189
}

0 commit comments

Comments
 (0)