Skip to content

Commit

Permalink
Update Go to 1.22 and testify to 1.9.0 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
adutra authored Apr 1, 2024
1 parent 5643f91 commit f124b7d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.22
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.22
- run: go test -race -coverprofile=coverage.out -covermode=atomic
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
6 changes: 4 additions & 2 deletions coalescer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ func (c *coalescer) defaultDeepMerge(v1, v2 reflect.Value) (reflect.Value, error
return c.deepMergeSlice(v1, v2)
case reflect.Array:
return c.deepMergeArray(v1, v2)
default:
return c.deepMergeAtomic(v1, v2)
}
return c.deepMergeAtomic(v1, v2)
}

// defaultDeepCopy is the default implementation of DeepCopyFunc. It is used when the coalescer is
Expand Down Expand Up @@ -111,6 +112,7 @@ func (c *coalescer) defaultDeepCopy(v reflect.Value) (reflect.Value, error) {
return c.deepCopySlice(v)
case reflect.Array:
return c.deepCopyArray(v)
default:
return c.deepCopyAtomic(v)
}
return c.deepCopyAtomic(v)
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/adutra/goalesce

go 1.18
go 1.22

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

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
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/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
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 h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
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=
24 changes: 13 additions & 11 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,22 @@ func WithAtomicMerge(t reflect.Type) Option {
// "trileans", that is, a type with 3 possible values: nil (its zero-value), false and true
// (contrary to booleans, with trileans false is NOT a zero-value).
// The merge of trileans obeys the following rules:
// v1 v2 merged
// nil nil nil
// nil false false
// nil true true
// false nil false
// false false false
// false true true
// true nil true
// true false false
// true true true
//
// v1 v2 merged
// nil nil nil
// nil false false
// nil true true
// false nil false
// false false false
// false true true
// true nil true
// true false false
// true true true
//
// The biggest difference with regular boolean pointers is that DeepMerge(&true, &false) will return
// &true for boolean pointers, while with trileans, it will return &false.
func WithTrileanMerge() Option {
return WithAtomicMerge(reflect.PtrTo(reflect.TypeOf(false)))
return WithAtomicMerge(reflect.PointerTo(reflect.TypeOf(false)))
}

// WithTypeMerger will defer the merge of the given type to the given custom merger. This option
Expand Down
2 changes: 1 addition & 1 deletion options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestWithAtomicMerge(t *testing.T) {

func TestWithTrileanMerge(t *testing.T) {
c := newCoalescer(WithTrileanMerge())
assert.NotNil(t, c.typeMergers[reflect.PtrTo(reflect.TypeOf(false))])
assert.NotNil(t, c.typeMergers[reflect.PointerTo(reflect.TypeOf(false))])
got, err := c.deepMerge(reflect.ValueOf(boolPtr(true)), reflect.ValueOf(boolPtr(false)))
assert.Equal(t, boolPtr(false), got.Interface())
assert.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions pointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func assertNotSame(t *testing.T, o1, o2 interface{}) bool {
return false
}
}
default:
}
return true
}

0 comments on commit f124b7d

Please sign in to comment.