Skip to content

Commit 45913df

Browse files
Add gofumpt (#254)
* Adding gofumpt in pre-commit * Bump golangci-lint * Apply gofumpt changes to the repo
1 parent f73abbb commit 45913df

Some content is hidden

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

53 files changed

+379
-218
lines changed

.golangci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ linters:
2727
- unconvert
2828
- unparam
2929
- whitespace
30+
- gofumpt
3031
linters-settings:
3132
funlen:
3233
lines: 90
@@ -51,4 +52,4 @@ issues:
5152
- gocyclo
5253
- gochecknoinits
5354
- dupl
54-
- staticcheck
55+
- staticcheck

.pre-commit-config.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
repos:
2+
- repo: https://github.com/Bahjat/pre-commit-golang
3+
rev: v1.0.1
4+
hooks:
5+
- id: gofumpt
6+
27
- repo: https://github.com/golangci/golangci-lint
3-
rev: v1.39.0
8+
rev: v1.46.2
49
hooks:
510
- id: golangci-lint

config.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package ffclient
33
import (
44
"context"
55
"errors"
6-
"github.com/thomaspoignant/go-feature-flag/ffnotifier"
76
"log"
87
"time"
98

9+
"github.com/thomaspoignant/go-feature-flag/ffnotifier"
10+
1011
"github.com/thomaspoignant/go-feature-flag/internal"
1112
"github.com/thomaspoignant/go-feature-flag/internal/notifier"
1213
)

config_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package ffclient_test
22

33
import (
4-
"github.com/aws/aws-sdk-go/aws"
5-
"github.com/stretchr/testify/assert"
64
"net/http"
75
"reflect"
86
"testing"
97
"time"
108

9+
"github.com/aws/aws-sdk-go/aws"
10+
"github.com/stretchr/testify/assert"
11+
1112
ffClient "github.com/thomaspoignant/go-feature-flag"
1213
)
1314

feature_flag_bench_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package ffclient_test
33
import (
44
"bytes"
55
"fmt"
6-
ffclient "github.com/thomaspoignant/go-feature-flag"
76
"io/ioutil"
87
"testing"
98
"text/template"
109
"time"
1110

11+
ffclient "github.com/thomaspoignant/go-feature-flag"
12+
1213
"github.com/thomaspoignant/go-feature-flag/ffuser"
1314
)
1415

@@ -31,7 +32,7 @@ func init() {
3132
})
3233

3334
flagFile, _ := ioutil.TempFile("", "")
34-
_ = ioutil.WriteFile(flagFile.Name(), buf.Bytes(), 0600)
35+
_ = ioutil.WriteFile(flagFile.Name(), buf.Bytes(), 0o600)
3536

3637
client, _ = ffclient.New(ffclient.Config{
3738
PollingInterval: 1 * time.Second,

ffexporter/common_test.go

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

33
import (
4-
"github.com/stretchr/testify/assert"
54
"testing"
65
"text/template"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
func Test_parseTemplate(t *testing.T) {

ffexporter/feature_event.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ func NewFeatureEvent(
1212
value interface{},
1313
variation string,
1414
failed bool,
15-
version float64) FeatureEvent {
15+
version float64,
16+
) FeatureEvent {
1617
contextKind := "user"
1718
if user.IsAnonymous() {
1819
contextKind = "anonymousUser"

ffexporter/file.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (f *File) Export(ctx context.Context, logger *log.Logger, featureEvents []F
6161

6262
filePath := f.OutputDir + "/" + filename
6363

64-
file, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
64+
file, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
6565
if err != nil {
6666
return err
6767
}

ffexporter/file_test.go

+66-33
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package ffexporter_test
22

33
import (
44
"context"
5-
"github.com/stretchr/testify/assert"
65
"io/ioutil"
76
"log"
87
"os"
98
"testing"
109

10+
"github.com/stretchr/testify/assert"
11+
1112
"github.com/thomaspoignant/go-feature-flag/ffexporter"
1213
)
1314

@@ -40,10 +41,14 @@ func TestFile_Export(t *testing.T) {
4041
fields: fields{},
4142
args: args{
4243
featureEvents: []ffexporter.FeatureEvent{
43-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
44-
Variation: "Default", Value: "YO", Default: false},
45-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
46-
Variation: "Default", Value: "YO2", Default: false, Version: 127},
44+
{
45+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
46+
Variation: "Default", Value: "YO", Default: false,
47+
},
48+
{
49+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
50+
Variation: "Default", Value: "YO2", Default: false, Version: 127,
51+
},
4752
},
4853
},
4954
expected: expected{
@@ -59,10 +64,14 @@ func TestFile_Export(t *testing.T) {
5964
},
6065
args: args{
6166
featureEvents: []ffexporter.FeatureEvent{
62-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
63-
Variation: "Default", Value: "YO", Default: false},
64-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
65-
Variation: "Default", Value: "YO2", Default: false},
67+
{
68+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
69+
Variation: "Default", Value: "YO", Default: false,
70+
},
71+
{
72+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
73+
Variation: "Default", Value: "YO2", Default: false,
74+
},
6675
},
6776
},
6877
expected: expected{
@@ -79,10 +88,14 @@ func TestFile_Export(t *testing.T) {
7988
},
8089
args: args{
8190
featureEvents: []ffexporter.FeatureEvent{
82-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
83-
Variation: "Default", Value: "YO", Default: false},
84-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
85-
Variation: "Default", Value: "YO2", Default: false},
91+
{
92+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
93+
Variation: "Default", Value: "YO", Default: false,
94+
},
95+
{
96+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
97+
Variation: "Default", Value: "YO2", Default: false,
98+
},
8699
},
87100
},
88101
expected: expected{
@@ -99,10 +112,14 @@ func TestFile_Export(t *testing.T) {
99112
},
100113
args: args{
101114
featureEvents: []ffexporter.FeatureEvent{
102-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
103-
Variation: "Default", Value: "YO", Default: false},
104-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
105-
Variation: "Default", Value: "YO2", Default: false},
115+
{
116+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
117+
Variation: "Default", Value: "YO", Default: false,
118+
},
119+
{
120+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
121+
Variation: "Default", Value: "YO2", Default: false,
122+
},
106123
},
107124
},
108125
expected: expected{
@@ -118,10 +135,14 @@ func TestFile_Export(t *testing.T) {
118135
},
119136
args: args{
120137
featureEvents: []ffexporter.FeatureEvent{
121-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
122-
Variation: "Default", Value: "YO", Default: false},
123-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
124-
Variation: "Default", Value: "YO2", Default: false, Version: 127},
138+
{
139+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
140+
Variation: "Default", Value: "YO", Default: false,
141+
},
142+
{
143+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
144+
Variation: "Default", Value: "YO2", Default: false, Version: 127,
145+
},
125146
},
126147
},
127148
expected: expected{
@@ -137,10 +158,14 @@ func TestFile_Export(t *testing.T) {
137158
},
138159
args: args{
139160
featureEvents: []ffexporter.FeatureEvent{
140-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
141-
Variation: "Default", Value: "YO", Default: false},
142-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
143-
Variation: "Default", Value: "YO2", Default: false},
161+
{
162+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
163+
Variation: "Default", Value: "YO", Default: false,
164+
},
165+
{
166+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
167+
Variation: "Default", Value: "YO2", Default: false,
168+
},
144169
},
145170
},
146171
},
@@ -152,10 +177,14 @@ func TestFile_Export(t *testing.T) {
152177
},
153178
args: args{
154179
featureEvents: []ffexporter.FeatureEvent{
155-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
156-
Variation: "Default", Value: "YO", Default: false},
157-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
158-
Variation: "Default", Value: "YO2", Default: false},
180+
{
181+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
182+
Variation: "Default", Value: "YO", Default: false,
183+
},
184+
{
185+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
186+
Variation: "Default", Value: "YO2", Default: false,
187+
},
159188
},
160189
},
161190
},
@@ -168,10 +197,14 @@ func TestFile_Export(t *testing.T) {
168197
},
169198
args: args{
170199
featureEvents: []ffexporter.FeatureEvent{
171-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
172-
Variation: "Default", Value: "YO", Default: false},
173-
{Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
174-
Variation: "Default", Value: "YO2", Default: false},
200+
{
201+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "ABCD", CreationDate: 1617970547, Key: "random-key",
202+
Variation: "Default", Value: "YO", Default: false,
203+
},
204+
{
205+
Kind: "feature", ContextKind: "anonymousUser", UserKey: "EFGH", CreationDate: 1617970701, Key: "random-key",
206+
Variation: "Default", Value: "YO2", Default: false,
207+
},
175208
},
176209
},
177210
},

ffexporter/google_cloud_storage.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package ffexporter
22

33
import (
4-
"cloud.google.com/go/storage"
54
"context"
65
"fmt"
7-
"github.com/thomaspoignant/go-feature-flag/internal/fflog"
8-
"google.golang.org/api/option"
96
"io"
107
"io/ioutil"
118
"log"
129
"os"
10+
11+
"cloud.google.com/go/storage"
12+
13+
"github.com/thomaspoignant/go-feature-flag/internal/fflog"
14+
"google.golang.org/api/option"
1315
)
1416

1517
type GoogleCloudStorage struct {

0 commit comments

Comments
 (0)