Skip to content

Commit bdfff11

Browse files
authored
Update deps and CI action (#36)
1 parent 0a28963 commit bdfff11

12 files changed

+31
-49
lines changed

.codecov.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
codecov:
2-
token: 25dd913a-2bf1-4be3-b13e-c06b079a4438
3-
41
coverage:
52
range: 80..100
63
round: down

.github/workflows/go.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Go
1+
name: Tests
22

33
on:
44
push:
@@ -13,9 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
go: ["1.18.x", "1.22.x"]
16+
go: ["1.18.x", "1.22.x", "1.23.x"]
1717
include:
18-
- go: 1.22.x
18+
- go: 1.23.x
1919
latest: true
2020

2121
steps:
@@ -46,3 +46,5 @@ jobs:
4646

4747
- name: Upload coverage to codecov.io
4848
uses: codecov/codecov-action@v4
49+
with:
50+
token: ${{ secrets.CODECOV_TOKEN }}

.golangci.yml

+7-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
linters-settings:
22
funlen:
3-
lines: 80
4-
statements: 72
3+
lines: 100
4+
statements: 80
55
gci:
66
sections:
77
- standard
@@ -11,14 +11,6 @@ linters-settings:
1111
min-complexity: 20
1212
goimports:
1313
local-prefixes: github.com/golangci/golangci-lint
14-
gomnd:
15-
settings:
16-
mnd:
17-
checks: # don't include the "operation" and "assign"
18-
- argument
19-
- case
20-
- condition
21-
- return
2214
lll:
2315
line-length: 120
2416
misspell:
@@ -33,7 +25,7 @@ linters:
3325
- errname
3426
- errorlint
3527
- exhaustive
36-
- exportloopref
28+
- copyloopvar
3729
- forbidigo
3830
- forcetypeassert
3931
- funlen
@@ -42,10 +34,10 @@ linters:
4234
- goconst
4335
- gocritic
4436
- gocyclo
45-
- goerr113
37+
- err113
4638
- gofmt
4739
- goimports
48-
- gomnd
40+
- mnd
4941
- gosec
5042
- gosimple
5143
- govet
@@ -73,18 +65,9 @@ issues:
7365
- staticcheck
7466
- gocyclo
7567
- gocognit
76-
- goerr113
68+
- err113
7769
- forcetypeassert
7870
- wrapcheck
7971
- gomnd
8072
- errorlint
81-
82-
run:
83-
skip-dirs:
84-
- scripts
85-
- test-results
86-
87-
# golangci configuration
88-
# https://github.com/golangci/golangci/wiki/Configuration
89-
service:
90-
golangci-lint-version: 1.50.x
73+
- unused

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
all: lint test
22

33
prepare:
4-
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.54.2
4+
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.60.3
55

66
build:
77
@go build -v ./...
@@ -10,8 +10,8 @@ test:
1010
@go test -cover -v ./...
1111

1212
cover:
13-
@go test -race -coverprofile=cover.out -coverpkg=./... ./...
14-
@go tool cover -html=cover.out -o cover.html
13+
@go test -race -coverprofile=coverage.txt -coverpkg=./... ./...
14+
@go tool cover -html=coverage.txt -o coverage.html
1515

1616
lint:
1717
golangci-lint --timeout=5m0s run -v ./...

decode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ func getDecodeFunc(typ reflect.Type) (DecodeFunc, error) {
1616
if typ.Implements(csvUnmarshaler) {
1717
return decodeCSVUnmarshaler, nil
1818
}
19-
if reflect.PtrTo(typ).Implements(csvUnmarshaler) {
19+
if reflect.PointerTo(typ).Implements(csvUnmarshaler) {
2020
return decodePtrCSVUnmarshaler, nil
2121
}
2222
if typ.Implements(textUnmarshaler) {
2323
return decodeTextUnmarshaler, nil
2424
}
25-
if reflect.PtrTo(typ).Implements(textUnmarshaler) {
25+
if reflect.PointerTo(typ).Implements(textUnmarshaler) {
2626
return decodePtrTextUnmarshaler, nil
2727
}
2828
return getDecodeFuncBaseType(typ)

decoder.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (d *Decoder) Decode(v any) (*DecodeResult, error) {
195195
for !d.shouldStop && len(d.rowsData) > 0 {
196196
// Reduce memory consumption by splitting the source data into chunks (10000 items each)
197197
// After each chunk is processed, resize the slice to allow Go to free the memory when necessary
198-
chunkSz := gofn.Min(10000, len(d.rowsData)) // nolint: gomnd
198+
chunkSz := gofn.Min(10000, len(d.rowsData)) //nolint:mnd
199199
chunk := d.rowsData[0:chunkSz]
200200
d.rowsData = d.rowsData[chunkSz:]
201201

@@ -470,7 +470,7 @@ func (d *Decoder) readRowData() error {
470470
ableToGetLine = false
471471
getLine = nil
472472
}
473-
rowDataItems := make([]*rowData, 0, 10000) // nolint: gomnd
473+
rowDataItems := make([]*rowData, 0, 10000) //nolint:mnd
474474

475475
for ; ; row++ {
476476
records, err := r.Read()
@@ -590,7 +590,7 @@ func (d *Decoder) validateColumnsMeta(colsMeta, colsMetaFromStruct []*decodeColu
590590
cfg := d.cfg
591591
// Make sure all column options valid
592592
for colKey := range cfg.columnConfigMap {
593-
if !gofn.ContainPred(colsMetaFromStruct, func(colMeta *decodeColumnMeta) bool {
593+
if !gofn.ContainBy(colsMetaFromStruct, func(colMeta *decodeColumnMeta) bool {
594594
return colMeta.headerKey == colKey || colMeta.parentKey == colKey
595595
}) {
596596
return fmt.Errorf("%w: column \"%s\" not found", ErrConfigOptionInvalid, colKey)
@@ -789,7 +789,7 @@ func (d *Decoder) parseInlineColumnDynamicType(typ reflect.Type, parent *decodeC
789789

790790
func (d *Decoder) parseDynamicInlineColumns(colsMetaFromStruct []*decodeColumnMeta, fileHeader []string) (
791791
[]*decodeColumnMeta, error) {
792-
newColsMetaFromStruct := make([]*decodeColumnMeta, 0, len(colsMetaFromStruct)*2) // nolint: gomnd
792+
newColsMetaFromStruct := make([]*decodeColumnMeta, 0, len(colsMetaFromStruct)*2) //nolint:mnd
793793
fileHeaderIndex := 0
794794
for i, colMetaFromStruct := range colsMetaFromStruct {
795795
if colMetaFromStruct.inlineColumnMeta == nil {

encode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ func getEncodeFunc(typ reflect.Type) (EncodeFunc, error) {
1616
if typ.Implements(csvMarshaler) {
1717
return encodeCSVMarshaler, nil
1818
}
19-
if reflect.PtrTo(typ).Implements(csvMarshaler) {
19+
if reflect.PointerTo(typ).Implements(csvMarshaler) {
2020
return encodePtrCSVMarshaler, nil
2121
}
2222
if typ.Implements(textMarshaler) {
2323
return encodeTextMarshaler, nil
2424
}
25-
if reflect.PtrTo(typ).Implements(textMarshaler) {
25+
if reflect.PointerTo(typ).Implements(textMarshaler) {
2626
return encodePtrTextMarshaler, nil
2727
}
2828
return getEncodeFuncBaseType(typ)

encoder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (e *Encoder) validateColumnsMeta(colsMeta []*encodeColumnMeta) error {
304304
cfg := e.cfg
305305
// Make sure all column options valid
306306
for colKey := range cfg.columnConfigMap {
307-
if !gofn.ContainPred(colsMeta, func(colMeta *encodeColumnMeta) bool {
307+
if !gofn.ContainBy(colsMeta, func(colMeta *encodeColumnMeta) bool {
308308
return colMeta.headerKey == colKey || colMeta.parentKey == colKey
309309
}) {
310310
return fmt.Errorf("%w: column \"%s\" not found", ErrConfigOptionInvalid, colKey)

errors_render_as_csv.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func defaultCSVRenderConfig() *CSVRenderConfig {
7171
RenderHeader: true,
7272
RenderRowNumberColumnIndex: 0,
7373
RenderLineNumberColumnIndex: 1,
74-
RenderCommonErrorColumnIndex: 2,
74+
RenderCommonErrorColumnIndex: 2, //nolint:mnd
7575

7676
LocalizeCellFields: true,
7777
LocalizeCellHeader: true,
@@ -96,7 +96,7 @@ func NewCSVRenderer(err *Errors, options ...func(*CSVRenderConfig)) (*CSVRendere
9696
opt(cfg)
9797
}
9898
// Validate/Correct the base columns to render
99-
baseColumns := make([]*int, 0, 3) // nolint: gomnd
99+
baseColumns := make([]*int, 0, 3) //nolint:mnd
100100
if cfg.RenderRowNumberColumnIndex >= 0 {
101101
baseColumns = append(baseColumns, &cfg.RenderRowNumberColumnIndex)
102102
}
@@ -351,7 +351,7 @@ func (r *CSVRenderer) localizeKeySkipError(key string, params ParameterMap) stri
351351

352352
func (r *CSVRenderer) estimateCSVBuffer(data [][]string) int {
353353
if len(data) <= 1 {
354-
return 512 // nolint: gomnd
354+
return 512 //nolint:mnd
355355
}
356356
row := data[1]
357357
rowSz := 0

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/hashicorp/go-multierror v1.1.1
77
github.com/stretchr/testify v1.9.0
8-
github.com/tiendc/gofn v1.8.0
8+
github.com/tiendc/gofn v1.11.0
99
)
1010

1111
require (

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
1111
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
1212
github.com/tiendc/go-rflutil v0.0.0-20231112145832-693b7b74d697 h1:BYWZUvxBkpnlC4MywWhO1bEch5L6cCc0t5FNVSUjZps=
1313
github.com/tiendc/go-rflutil v0.0.0-20231112145832-693b7b74d697/go.mod h1:nSMBac9C+G4b8nvxSgPZ0rmhrLonJ5ZdknynSKxQhL8=
14-
github.com/tiendc/gofn v1.8.0 h1:ivD6twigyA3lpXnkC2cVgN2LWUmyisSV6MmYf1f3fUQ=
15-
github.com/tiendc/gofn v1.8.0/go.mod h1:uevHlES37QrasSvoZxBUcooejk7QfvBCfrJ809b+giA=
14+
github.com/tiendc/gofn v1.11.0 h1:rjXJ2tZ6L96ICwBkbVv0ubDOvrGRo1QMXhhq90xZTBw=
15+
github.com/tiendc/gofn v1.11.0/go.mod h1:uevHlES37QrasSvoZxBUcooejk7QfvBCfrJ809b+giA=
1616
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1717
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1818
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func processTemplate(templ string, params ParameterMap) (detail string, retErr e
3232
return
3333
}
3434

35-
buf := bytes.NewBuffer(make([]byte, 0, 100)) // nolint: gomnd
35+
buf := bytes.NewBuffer(make([]byte, 0, 100)) //nolint:mnd
3636
err = t.Execute(buf, params)
3737
if err != nil {
3838
retErr = multierror.Append(retErr, err)

0 commit comments

Comments
 (0)