Skip to content

Commit

Permalink
Update deps and CI action (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiendc committed Sep 11, 2024
1 parent fd7c970 commit fca8bc7
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coverage:
range: 80..100
round: down
round: up
precision: 2

status:
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go
name: Tests

on:
push:
Expand All @@ -13,22 +13,22 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.18.x", "1.21.x"]
go: ["1.18.x", "1.22.x", "1.23.x"]
include:
- go: 1.21.x
- go: 1.23.x
latest: true

steps:
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Load cached dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -45,4 +45,6 @@ jobs:
run: make cover

- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
28 changes: 5 additions & 23 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ linters-settings:
min-complexity: 20
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
settings:
mnd:
checks: # don't include the "operation" and "assign"
- argument
- case
- condition
- return
lll:
line-length: 120
misspell:
Expand All @@ -33,7 +25,7 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- copyloopvar
- forbidigo
- forcetypeassert
- funlen
Expand All @@ -42,10 +34,10 @@ linters:
- goconst
- gocritic
- gocyclo
- goerr113
- err113
- gofmt
- goimports
- gomnd
- mnd
- gosec
- gosimple
- govet
Expand Down Expand Up @@ -73,19 +65,9 @@ issues:
- staticcheck
- gocyclo
- gocognit
- goerr113
- err113
- forcetypeassert
- wrapcheck
- gomnd
- errorlint
- unused

run:
skip-dirs:
- scripts
- test-results

# golangci configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.50.x
- unused
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: lint test

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

build:
@go build -v ./...
Expand All @@ -10,8 +10,8 @@ test:
@go test -cover -v ./...

cover:
@go test -race -coverprofile=cover.out -coverpkg=./... ./...
@go tool cover -html=cover.out -o cover.html
@go test -race -coverprofile=coverage.txt -coverpkg=./... ./...
@go tool cover -html=coverage.txt -o coverage.html

lint:
golangci-lint --timeout=5m0s run -v ./...
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,6 @@ BenchmarkCopy/Deepcopier-10 42990 27988 ns/op

- You are welcome to make pull requests for new functions and bug fixes.

## Authors

- Dao Cong Tien ([tiendc](https://github.com/tiendc))

## License

- [MIT License](LICENSE)
Expand Down
4 changes: 2 additions & 2 deletions build_copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type cacheKey struct {

var (
// copierCacheMap global cache for any parsed type
copierCacheMap = make(map[cacheKey]copier, 10) // nolint: gomnd
copierCacheMap = make(map[cacheKey]copier, 10) //nolint:mnd

// mu read/write cache lock
mu sync.RWMutex
Expand Down Expand Up @@ -60,7 +60,7 @@ func (ctx *Context) prepare() {
ctx.copierCacheMap = copierCacheMap
ctx.mu = &mu
} else {
ctx.copierCacheMap = make(map[cacheKey]copier, 5) // nolint: gomnd
ctx.copierCacheMap = make(map[cacheKey]copier, 5) //nolint:mnd
ctx.mu = &sync.RWMutex{}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/tiendc/go-deepcopy

go 1.18

require github.com/stretchr/testify v1.8.0
require github.com/stretchr/testify v1.9.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
9 changes: 2 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8 changes: 4 additions & 4 deletions struct_copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ func (c *structFieldMethodCopier) Copy(dst, src reflect.Value) error {
return fmt.Errorf("%w: accessing unexported field requires it to be addressable",
ErrValueUnaddressable)
}
src = reflect.NewAt(src.Type(), unsafe.Pointer(src.UnsafeAddr())).Elem()
src = reflect.NewAt(src.Type(), unsafe.Pointer(src.UnsafeAddr())).Elem() //nolint:gosec
}
dst = dst.Addr().Method(c.dstMethod)
if c.dstMethodUnexported {
dst = reflect.NewAt(dst.Type(), unsafe.Pointer(dst.UnsafeAddr())).Elem()
dst = reflect.NewAt(dst.Type(), unsafe.Pointer(dst.UnsafeAddr())).Elem() //nolint:gosec
}
errVal := dst.Call([]reflect.Value{src})[0]
if errVal.IsNil() {
Expand Down Expand Up @@ -292,11 +292,11 @@ func (c *structUnexportedFieldCopier) Copy(dst, src reflect.Value) error {
return fmt.Errorf("%w: accessing unexported field requires it to be addressable",
ErrValueUnaddressable)
}
src = reflect.NewAt(src.Type(), unsafe.Pointer(src.UnsafeAddr())).Elem()
src = reflect.NewAt(src.Type(), unsafe.Pointer(src.UnsafeAddr())).Elem() //nolint:gosec
}
dst = dst.Field(c.dstField)
if c.dstFieldUnexported {
dst = reflect.NewAt(dst.Type(), unsafe.Pointer(dst.UnsafeAddr())).Elem()
dst = reflect.NewAt(dst.Type(), unsafe.Pointer(dst.UnsafeAddr())).Elem() //nolint:gosec
}
return c.copier.Copy(dst, src)
}

0 comments on commit fca8bc7

Please sign in to comment.