Skip to content

Commit 54a0ff7

Browse files
authored
chore: enable Go modules and modernize CI (#374)
1 parent b2f570e commit 54a0ff7

File tree

9 files changed

+82
-82
lines changed

9 files changed

+82
-82
lines changed

.github/workflows/go.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Go
22
on:
33
push:
4-
branches: [ main ]
4+
branches: [main]
55
paths:
66
- '**.go'
77
- 'go.mod'
@@ -14,47 +14,39 @@ on:
1414
- '.golangci.yml'
1515
- '.github/workflows/go.yml'
1616
env:
17-
GOPROXY: "https://proxy.golang.org"
17+
GOPROXY: 'https://proxy.golang.org'
1818

1919
jobs:
2020
lint:
2121
name: Lint
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: Checkout code
25-
uses: actions/checkout@v2
26-
- name: Init Go Modules
27-
run: |
28-
go mod init github.com/go-ini/ini
29-
go mod tidy
25+
uses: actions/checkout@v6
26+
- name: Setup Go
27+
uses: actions/setup-go@v6
28+
with:
29+
go-version: stable
3030
- name: Run golangci-lint
31-
uses: golangci/golangci-lint-action@v2
31+
uses: golangci/golangci-lint-action@v9
3232
with:
3333
version: latest
3434
args: --timeout=30m
35-
skip-pkg-cache: true # Wrokaround of the "tar" problem: https://github.com/golangci/golangci-lint-action/issues/244
3635

3736
test:
3837
name: Test
3938
strategy:
4039
matrix:
41-
go-version: [ 1.13.x, 1.14.x, 1.15.x, 1.16.x, 1.17.x, 1.18.x ]
42-
platform: [ ubuntu-latest, macos-latest, windows-latest ]
40+
go-version: [1.24.x, 1.25.x]
41+
platform: [ubuntu-latest, macos-latest, windows-latest]
4342
runs-on: ${{ matrix.platform }}
4443
steps:
45-
- name: Install Go
46-
uses: actions/setup-go@v2
44+
- name: Checkout code
45+
uses: actions/checkout@v6
46+
- name: Setup Go
47+
uses: actions/setup-go@v6
4748
with:
4849
go-version: ${{ matrix.go-version }}
49-
- name: Checkout code
50-
uses: actions/checkout@v2
5150
- name: Run tests with coverage
5251
run: |
53-
go mod init github.com/go-ini/ini
54-
go mod tidy
55-
go test -v -race -coverprofile=coverage -covermode=atomic ./...
56-
- name: Upload coverage report to Codecov
57-
uses: codecov/codecov-action@v1.5.0
58-
with:
59-
file: ./coverage
60-
flags: unittests
52+
go test -v -race ./...

.github/workflows/lsif.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.golangci.yml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1-
linters-settings:
2-
staticcheck:
3-
checks: [
4-
"all",
5-
"-SA1019" # There are valid use cases of strings.Title
6-
]
7-
nakedret:
8-
max-func-lines: 0 # Disallow any unnamed return statement
9-
1+
version: "2"
102
linters:
113
enable:
12-
- deadcode
13-
- errcheck
14-
- gosimple
15-
- govet
16-
- ineffassign
17-
- staticcheck
18-
- structcheck
19-
- typecheck
20-
- unused
21-
- varcheck
224
- nakedret
23-
- gofmt
245
- rowserrcheck
256
- unconvert
26-
- goimports
277
- unparam
8+
settings:
9+
govet:
10+
disable:
11+
# printf: non-constant format string in call to fmt.Errorf (govet)
12+
# showing up since golangci-lint version 1.60.1
13+
- printf
14+
nakedret:
15+
max-func-lines: 0 # Disallow any unnamed return statement
16+
exclusions:
17+
generated: lax
18+
presets:
19+
- comments
20+
- common-false-positives
21+
- legacy
22+
- std-error-handling
23+
paths:
24+
- third_party$
25+
- builtin$
26+
- examples$
27+
formatters:
28+
enable:
29+
- gofmt
30+
- goimports
31+
exclusions:
32+
generated: lax
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# INI
22

33
[![GitHub Workflow Status](https://img.shields.io/github/checks-status/go-ini/ini/main?logo=github&style=for-the-badge)](https://github.com/go-ini/ini/actions?query=branch%3Amain)
4-
[![codecov](https://img.shields.io/codecov/c/github/go-ini/ini/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/go-ini/ini)
54
[![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/go-ini/ini?tab=doc)
6-
[![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/go-ini/ini)
75

86
![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200)
97

@@ -27,10 +25,14 @@ Package ini provides INI file read and write functionality in Go.
2725
The minimum requirement of Go is **1.13**.
2826

2927
```sh
30-
$ go get gopkg.in/ini.v1
28+
$ go get gopkg.in/ini.v1@latest
3129
```
3230

33-
Please add `-u` flag to update in the future.
31+
> [!NOTE]
32+
> If you previously used `github.com/go-ini/ini` as the import path in your project, without updating all of your code, you can use the following command to replace the import path in your `go.mod`:
33+
> ```zsh
34+
> go mod edit -replace github.com/go-ini/ini=gopkg.in/ini.v1@latest
35+
> ```
3436
3537
## Getting Help
3638

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module gopkg.in/ini.v1
2+
3+
go 1.13
4+
5+
require github.com/stretchr/testify v1.11.1

go.sum

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
5+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
6+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
7+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
8+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
9+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
10+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
11+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
12+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
13+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
14+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
15+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
16+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
18+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
19+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

key.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (k *Key) transformValue(val string) string {
170170
}
171171

172172
// Substitute by new value and take off leading '%(' and trailing ')s'.
173-
val = strings.Replace(val, vr, nk.value, -1)
173+
val = strings.ReplaceAll(val, vr, nk.value)
174174
}
175175
return val
176176
}
@@ -429,7 +429,7 @@ func (k *Key) InUint64(defaultVal uint64, candidates []uint64) uint64 {
429429
func (k *Key) InTimeFormat(format string, defaultVal time.Time, candidates []time.Time) time.Time {
430430
val := k.MustTimeFormat(format)
431431
for _, cand := range candidates {
432-
if val == cand {
432+
if val.Equal(cand) {
433433
return val
434434
}
435435
}

parser.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ func readKeyName(delimiters string, in []byte) (string, int, error) {
130130

131131
// Check if key name surrounded by quotes.
132132
var keyQuote string
133-
if line[0] == '"' {
133+
switch line[0] {
134+
case '"':
134135
if len(line) > 6 && line[0:3] == `"""` {
135136
keyQuote = `"""`
136137
} else {
137138
keyQuote = `"`
138139
}
139-
} else if line[0] == '`' {
140+
case '`':
140141
keyQuote = "`"
141142
}
142143

@@ -253,7 +254,7 @@ func (p *parser) readValue(in []byte, bufferSize int) (string, error) {
253254
}
254255

255256
if p.options.UnescapeValueDoubleQuotes && valQuote == `"` {
256-
return strings.Replace(line[startIdx:pos+startIdx], `\"`, `"`, -1), nil
257+
return strings.ReplaceAll(line[startIdx:pos+startIdx], `\"`, `"`), nil
257258
}
258259
return line[startIdx : pos+startIdx], nil
259260
}

struct_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func Test_MapToStruct(t *testing.T) {
243243
assert.Equal(t, "[192.168 10.11]", fmt.Sprint(ts.Others.Coordinates))
244244
assert.Equal(t, "[true false]", fmt.Sprint(ts.Others.Flags))
245245
assert.Equal(t, "Hello world!", ts.Others.Note)
246-
assert.Equal(t, 2.8, ts.TestEmbeded.GPA)
246+
assert.Equal(t, 2.8, ts.GPA)
247247

248248
assert.Equal(t, "HangZhou,Boston", strings.Join(ts.OthersPtr.Cities, ","))
249249
assert.Equal(t, ti.String(), ts.OthersPtr.Visits[0].String())

0 commit comments

Comments
 (0)