Skip to content

Commit 3b351ff

Browse files
committed
minor updates to get familiar with the code again
1 parent 0dca95b commit 3b351ff

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

+13880
-2706
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v3
1717
with:
18-
go-version: 1.20.1
18+
go-version: 1.24.0
1919

2020
- name: build
2121
run: make build

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/setup-go@v3
1515
with:
16-
go-version: 1.20.1
16+
go-version: 1.24.0
1717
- uses: actions/checkout@v3
1818
- name: golangci-lint
1919
uses: golangci/golangci-lint-action@v3

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/lucapette/fakedata
22

3-
go 1.20
3+
go 1.24.0
44

55
require (
66
github.com/gofrs/uuid v4.4.0+incompatible
77
github.com/kr/pretty v0.3.1
8-
github.com/spf13/pflag v1.0.5
9-
golang.org/x/text v0.9.0
8+
github.com/spf13/pflag v1.0.10
9+
golang.org/x/text v0.32.0
1010
)
1111

1212
require (
1313
github.com/kr/text v0.2.0 // indirect
14-
github.com/rogpeppe/go-internal v1.10.0 // indirect
14+
github.com/rogpeppe/go-internal v1.14.1 // indirect
1515
)

go.sum

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2-
github.com/gofrs/uuid v4.3.0+incompatible h1:CaSVZxm5B+7o45rtab4jC2G37WGYX1zQfuU2i6DSvnc=
3-
github.com/gofrs/uuid v4.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
42
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
53
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
6-
github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3 h1:dhwb1Ev84SKKVBfLuhR4bw/29yYHzwtTyTLUWWnvYxI=
7-
github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3/go.mod h1:Bvhd+E3laJ0AVkG0c9rmtZcnhV0HQ3+c3YxxqTvc/gA=
84
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
95
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
10-
github.com/kr/text v0.0.0-20160504234017-7cafcd837844 h1:kpzneEBeC0dMewP3gr/fADv1OlblH9r1goWVwpOt3TU=
11-
github.com/kr/text v0.0.0-20160504234017-7cafcd837844/go.mod h1:sjUstKUATFIcff4qlB53Kml0wQPtJVc/3fWrmuUmcfA=
126
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
137
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
148
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
159
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
16-
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
17-
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
18-
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
19-
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
20-
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
21-
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
22-
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
23-
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
10+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
11+
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
12+
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
13+
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
14+
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
15+
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=

pkg/fakedata/completion.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ _fakedata () {
3232
}
3333
compdef _fakedata fakedata`
3434

35-
const fishTemplate = `
36-
complete -c fakedata -a '%s'
37-
`
35+
const fishTemplate = "complete -c fakedata -a '%s'"
3836

3937
func getTemplate(shell string) (string, error) {
4038
switch shell {
@@ -50,7 +48,7 @@ func getTemplate(shell string) (string, error) {
5048
}
5149

5250
// GetCompletionFunc returns a string representing a completion function for the
53-
// given shell. It returns an error for unsupported shell.
51+
// given shell. It returns an error for unsupported shells.
5452
func GetCompletionFunc(shell string) (string, error) {
5553
t, err := getTemplate(shell)
5654
if err != nil {
@@ -61,7 +59,10 @@ func GetCompletionFunc(shell string) (string, error) {
6159
allCliArgs := &bytes.Buffer{}
6260

6361
for _, gen := range NewGenerators() {
64-
fmt.Fprintf(gens, gen.Name+" ")
62+
_, err = fmt.Fprint(gens, gen.Name+" ")
63+
if err != nil {
64+
return "", err
65+
}
6566
}
6667

6768
pflag.VisitAll(func(f *pflag.Flag) {

pkg/fakedata/generator.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,38 +127,40 @@ func domain() string {
127127
}
128128

129129
func date(options string) (f func() string, err error) {
130-
var min, max string
130+
var minDate, maxDate string
131131

132132
endDate := time.Now()
133133
startDate := endDate.AddDate(-1, 0, 0)
134134

135135
dateRange := strings.Split(options, ",")
136-
min = dateRange[0]
136+
minDate = dateRange[0]
137137

138138
if len(dateRange) > 1 {
139-
max = dateRange[1]
139+
maxDate = dateRange[1]
140140
}
141141

142-
if len(min) > 0 {
143-
if len(max) > 0 {
144-
formattedMax := fmt.Sprintf("%sT00:00:00.000Z", max)
142+
if len(minDate) > 0 {
143+
if len(maxDate) > 0 {
144+
formattedMax := fmt.Sprintf("%sT00:00:00.000Z", maxDate)
145145

146-
date, err := time.Parse("2006-01-02T15:04:05.000Z", formattedMax)
146+
var d time.Time
147+
d, err = time.Parse("2006-01-02T15:04:05.000Z", formattedMax)
147148
if err != nil {
148-
return nil, fmt.Errorf("problem parsing max date: %v", err)
149+
return nil, fmt.Errorf("problem parsing maxDate date: %v", err)
149150
}
150151

151-
endDate = date
152+
endDate = d
152153
}
153154

154-
formattedMin := fmt.Sprintf("%sT00:00:00.000Z", min)
155+
formattedMin := fmt.Sprintf("%sT00:00:00.000Z", minDate)
155156

156-
date, err := time.Parse("2006-01-02T15:04:05.000Z", formattedMin)
157+
var d time.Time
158+
d, err = time.Parse("2006-01-02T15:04:05.000Z", formattedMin)
157159
if err != nil {
158160
return nil, fmt.Errorf("problem parsing mix date: %v", err)
159161
}
160162

161-
startDate = date
163+
startDate = d
162164
}
163165

164166
if startDate.After(endDate) {
@@ -171,8 +173,8 @@ func date(options string) (f func() string, err error) {
171173
}
172174

173175
func integer(options string) (func() string, error) {
174-
min := 0
175-
max := 1000
176+
minInt := 0
177+
maxInt := 1000
176178
var low, high string
177179
intRange := strings.Split(options, ",")
178180
low = intRange[0]
@@ -187,23 +189,23 @@ func integer(options string) (func() string, error) {
187189
return nil, fmt.Errorf("could not convert min: %v", err)
188190
}
189191

190-
min = m
192+
minInt = m
191193

192194
if len(high) > 0 {
193-
m, err := strconv.Atoi(high)
195+
m, err = strconv.Atoi(high)
194196
if err != nil {
195197
return nil, fmt.Errorf("could not convert max: %v", err)
196198
}
197199

198-
max = m
200+
maxInt = m
199201
}
200202
}
201203

202-
if min > max {
203-
return nil, fmt.Errorf("max(%d) is smaller than min(%d)", max, min)
204+
if minInt > maxInt {
205+
return nil, fmt.Errorf("max(%d) is smaller than min(%d)", maxInt, minInt)
204206
}
205207

206-
return func() string { return strconv.Itoa(min + rand.Intn(max+1-min)) }, nil
208+
return func() string { return strconv.Itoa(minInt + rand.Intn(maxInt+1-minInt)) }, nil
207209
}
208210

209211
func file(path string) (func() string, error) {
@@ -213,12 +215,12 @@ func file(path string) (func() string, error) {
213215

214216
filePath := strings.Trim(path, "'\"")
215217

216-
file, err := os.ReadFile(filePath)
218+
f, err := os.ReadFile(filePath)
217219
if err != nil {
218220
return nil, fmt.Errorf("could not read file %s: %v", filePath, err)
219221
}
220222

221-
content := strings.Split(strings.Trim(string(file), "\n"), "\n")
223+
content := strings.Split(strings.Trim(string(f), "\n"), "\n")
222224
list := withList(content)
223225

224226
return func() string { return list() }, nil

vendor/github.com/rogpeppe/go-internal/fmtsort/sort.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/spf13/pflag/.editorconfig

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/spf13/pflag/.golangci.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/spf13/pflag/README.md

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)