Skip to content

Commit

Permalink
Bump dependencies (#307)
Browse files Browse the repository at this point in the history
* Bump dependencies

* Fix lint issues

* Bump dependencies
  • Loading branch information
nhatthm authored Aug 22, 2024
1 parent 2b47ae4 commit c00c367
Show file tree
Hide file tree
Showing 34 changed files with 534 additions and 595 deletions.
17 changes: 6 additions & 11 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,29 @@ linters:
enable-all: true
disable:
- contextcheck
- deadcode
- depguard
- exhaustivestruct
- exhaustruct
- execinquery
- forbidigo
- forcetypeassert
- gci
- gochecknoglobals
- goerr113
- golint
- err113
- gomnd
- gomoddirectives
- ifshort
- interfacer
- ireturn
- lll
- maligned
- mnd
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
- nonamedreturns
- nosnakecase
- paralleltest
- perfsprint
- rowserrcheck # https://github.com/golangci/golangci-lint/issues/2649
- scopelint
- sqlclosecheck # https://github.com/golangci/golangci-lint/issues/2649
- structcheck
- tagalign
- tagliatelle
- testifylint
- testpackage
- varcheck
- varnamelen
- wastedassign # https://github.com/golangci/golangci-lint/issues/2649
- wrapcheck
Expand All @@ -67,6 +60,8 @@ issues:
- goerr113
- gomnd
- maintidx
- mnd
- nilnil
- noctx
- rowserrcheck
path: "_test.go"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ MODULE_NAME=otelsql

VENDOR_DIR = vendor

GOLANGCI_LINT_VERSION ?= v1.55.2
GOLANGCI_LINT_VERSION ?= v1.60.1

GO ?= go
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion attribute/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func KeyFromNamedValue(arg driver.NamedValue) attribute.Key {

// KeyValue returns an attribute.KeyValue from a given value.
// nolint: cyclop
func KeyValue(key attribute.Key, val interface{}) attribute.KeyValue {
func KeyValue(key attribute.Key, val any) attribute.KeyValue {
switch v := val.(type) {
case nil:
return key.String("")
Expand Down
9 changes: 4 additions & 5 deletions attribute/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func BenchmarkFromNamedValue(b *testing.B) {

longString := strings.Repeat(pattern, 17)

data := []interface{}{
data := []any{
nil,
10,
int64(42),
Expand All @@ -45,8 +45,7 @@ func BenchmarkFromNamedValue(b *testing.B) {
map[string]string{"hello": "world"},
}

max := len(data)
namedValues := make([]driver.NamedValue, max)
namedValues := make([]driver.NamedValue, len(data))

for i, v := range data {
namedValues[i] = driver.NamedValue{
Expand Down Expand Up @@ -119,7 +118,7 @@ func TestKeyValue(t *testing.T) {

testCases := []struct {
scenario string
value interface{}
value any
expected attribute.KeyValue
}{
{
Expand Down Expand Up @@ -316,7 +315,7 @@ func TestKeyValueDuration(t *testing.T) {
}
}

func ptrOf(v interface{}) interface{} {
func ptrOf(v any) any {
val := reflect.ValueOf(v)
p := reflect.New(val.Type())

Expand Down
2 changes: 1 addition & 1 deletion begin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type beginFunc func(ctx context.Context, opts driver.TxOptions) (driver.Tx, erro

// nopBegin pings nothing.
func nopBegin(_ context.Context, _ driver.TxOptions) (driver.Tx, error) {
return nil, nil
return nil, nil //nolint: nilnil
}

func ensureBegin(conn driver.Conn) beginFunc {
Expand Down
4 changes: 2 additions & 2 deletions conn_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestWrapConn(t *testing.T) {
connCloseFunc
connBeginFunc
}{
connPrepareFunc: func(query string) (driver.Stmt, error) {
connPrepareFunc: func(string) (driver.Stmt, error) {
return nil, expectedPrepareError
},
connCloseFunc: func() error {
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestWrapConn(t *testing.T) {
testCases := []struct {
scenario string
parent driver.Conn
expectedType interface{}
expectedType any
assert func(t *testing.T, conn driver.Conn)
}{
{
Expand Down
28 changes: 14 additions & 14 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestRegister_OpenError(t *testing.T) {
driver.Driver
driver.DriverContext
}{
DriverContext: driverOpenConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: driverOpenConnectorFunc(func(string) (driver.Connector, error) {
return struct {
driverDriverFunc
driverConnectFunc
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestWrap_DriverContext_Driver(t *testing.T) {
driver.Driver
driver.DriverContext
}{
DriverContext: driverOpenConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: driverOpenConnectorFunc(func(string) (driver.Connector, error) {
return nil, nil
}),
}
Expand All @@ -117,7 +117,7 @@ func TestWrap_DriverContext_OpenConnectorError(t *testing.T) {
driver.Driver
driver.DriverContext
}{
DriverContext: driverOpenConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: driverOpenConnectorFunc(func(string) (driver.Connector, error) {
return nil, errors.New("open connector error")
}),
}
Expand All @@ -138,12 +138,12 @@ func TestWrap_DriverContext_ConnectError(t *testing.T) {
driver.Driver
driver.DriverContext
}{
DriverContext: driverOpenConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: driverOpenConnectorFunc(func(string) (driver.Connector, error) {
return struct {
driverDriverFunc
driverConnectFunc
}{
driverConnectFunc: func(ctx context.Context) (driver.Conn, error) {
driverConnectFunc: func(context.Context) (driver.Conn, error) {
return nil, errors.New("connect error")
},
}, nil
Expand Down Expand Up @@ -172,13 +172,13 @@ func TestWrap_DriverContext_ConnectNamedValueChecker(t *testing.T) {
driver.Driver
driver.DriverContext
}{
DriverContext: driverOpenConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: driverOpenConnectorFunc(func(string) (driver.Connector, error) {
return struct {
driverDriverFunc
driverConnectFunc
driverNamedValueCheckerFunc
}{
driverConnectFunc: func(ctx context.Context) (driver.Conn, error) {
driverConnectFunc: func(context.Context) (driver.Conn, error) {
return m.(driver.Conn), nil
},
}, nil
Expand All @@ -203,7 +203,7 @@ func TestWrap_DriverContext_CloseBeforeOpenConnector(t *testing.T) {
driver.Driver
driver.DriverContext
}{
DriverContext: driverOpenConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: driverOpenConnectorFunc(func(string) (driver.Connector, error) {
return struct {
driverDriverFunc
driverConnectFunc
Expand Down Expand Up @@ -232,13 +232,13 @@ func TestWrap_DriverContext_CloseError(t *testing.T) {
driver.Driver
driver.DriverContext
}{
DriverContext: driverOpenConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: driverOpenConnectorFunc(func(string) (driver.Connector, error) {
return struct {
driverDriverFunc
driverConnectFunc
driverCloseFunc
}{
driverConnectFunc: func(ctx context.Context) (driver.Conn, error) {
driverConnectFunc: func(context.Context) (driver.Conn, error) {
return nil, nil
},
driverCloseFunc: func() error {
Expand Down Expand Up @@ -2841,7 +2841,7 @@ func contextWithSampleSpan() context.Context {
return oteltest.BackgroundWithSpanContext(sampleParentSpanIDs())
}

func assertSpanIsRoot(t assert.TestingT, span oteltest.Span, msgAndArgs ...interface{}) bool {
func assertSpanIsRoot(t assert.TestingT, span oteltest.Span, msgAndArgs ...any) bool {
return assert.Equal(t, span.Parent.TraceID, oteltest.NilTraceID.String(), msgAndArgs...) &&
assert.Equal(t, span.Parent.SpanID, oteltest.NilSpanID.String(), msgAndArgs...)
}
Expand Down Expand Up @@ -2918,14 +2918,14 @@ func assertSpansHaveSameRoot(t assert.TestingT, actual []oteltest.Span) bool {
return result
}

func getFixture(file string, args ...interface{}) string {
func getFixture(file string, args ...any) string {
data, err := os.ReadFile(filepath.Clean(file))
mustNotFail(err)

return fmt.Sprintf(string(data), args...)
}

func expectedMetricsFromFile(file string, args ...interface{}) string { // nolint: unparam
func expectedMetricsFromFile(file string, args ...any) string { // nolint: unparam
return getFixture("resources/fixtures/metrics/"+file, args...)
}

Expand Down Expand Up @@ -2961,7 +2961,7 @@ func expectedCustomMetricOK() string {
return expectedMetricsFromFile("custom_ok.json")
}

func expectedTracesFromFile(file string, args ...interface{}) string {
func expectedTracesFromFile(file string, args ...any) string {
return getFixture("resources/fixtures/traces/"+file, args...)
}

Expand Down
2 changes: 1 addition & 1 deletion exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type execContextFunc func(ctx context.Context, query string, args []driver.Named

// nopExecContext executes nothing.
func nopExecContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Result, error) {
return nil, nil
return nil, nil //nolint: nilnil
}

// skippedExecContext always returns driver.ErrSkip.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.24.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
8 changes: 4 additions & 4 deletions internal/test/assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import (
)

// Func asserts actual input.
type Func func(t assert.TestingT, actual string, msgAndArgs ...interface{}) bool
type Func func(t assert.TestingT, actual string, msgAndArgs ...any) bool

// Equal creates a new Func to check whether the two values are equal.
func Equal(expect string) Func {
return func(t assert.TestingT, actual string, msgAndArgs ...interface{}) bool {
return func(t assert.TestingT, actual string, msgAndArgs ...any) bool {
return assert.Equal(t, expect, actual, msgAndArgs...)
}
}

// EqualJSON creates a new Func to check whether the two JSON values are equal.
func EqualJSON(expect string) Func {
return func(t assert.TestingT, actual string, msgAndArgs ...interface{}) bool {
return func(t assert.TestingT, actual string, msgAndArgs ...any) bool {
return assertjson.Equal(t, []byte(expect), []byte(actual), msgAndArgs...)
}
}

// Nop creates a new Func that does not assert anything.
func Nop() Func {
return func(_ assert.TestingT, _ string, _ ...interface{}) bool {
return func(_ assert.TestingT, _ string, _ ...any) bool {
return true
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/test/oteltest/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func fixTracesOutput(out string) string {
}

func chainAsserters(fs ...testassert.Func) testassert.Func {
return func(t assert.TestingT, actual string, msgAndArgs ...interface{}) bool {
return func(t assert.TestingT, actual string, msgAndArgs ...any) bool {
for _, f := range fs {
if !f(t, actual, msgAndArgs...) {
return false
Expand All @@ -333,7 +333,7 @@ func chainAsserters(fs ...testassert.Func) testassert.Func {
}

func matchTraces(f func(t assert.TestingT, actual []Span) bool) testassert.Func {
return func(t assert.TestingT, actual string, msgAndArgs ...interface{}) bool {
return func(t assert.TestingT, actual string, _ ...any) bool {
var spans []Span

if actual == "" {
Expand Down
4 changes: 2 additions & 2 deletions internal/test/oteltest/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type SpanContext struct {
type SpanAttribute struct {
Key string `json:"Key"`
Value struct {
Type string `json:"Type"`
Value interface{} `json:"Value"`
Type string `json:"Type"`
Value any `json:"Value"`
} `json:"Value"`
}
4 changes: 2 additions & 2 deletions internal/test/sqlmock/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func DriverContext(mocks ...func(Sqlmock)) driver.DriverContext {
driver.Driver
driver.DriverContext
}{
DriverContext: openConnectorFunc(func(name string) (driver.Connector, error) {
DriverContext: openConnectorFunc(func(string) (driver.Connector, error) {
if err != nil {
return nil, err
}
Expand All @@ -29,7 +29,7 @@ func DriverContext(mocks ...func(Sqlmock)) driver.DriverContext {
driverFunc
connectFunc
}{
connectFunc: func(ctx context.Context) (driver.Conn, error) {
connectFunc: func(context.Context) (driver.Conn, error) {
for _, mock := range mocks {
mock(m)
}
Expand Down
4 changes: 2 additions & 2 deletions ping_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestChainPingFuncMiddlewares(t *testing.T) {
stack := make([]string, 0)

pushPingFunc := func(s string) pingFunc {
return func(ctx context.Context) error {
return func(context.Context) error {
stack = append(stack, s)

return nil
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestPingStats(t *testing.T) {
}{
{
scenario: "error",
ping: func(_ context.Context) error {
ping: func(context.Context) error {
return errors.New("error")
},
expected: `[
Expand Down
2 changes: 1 addition & 1 deletion prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type prepareContextFunc func(ctx context.Context, query string) (driver.Stmt, er

// nopPrepareContext prepares nothing.
func nopPrepareContext(_ context.Context, _ string) (driver.Stmt, error) {
return nil, nil
return nil, nil //nolint: nilnil
}

func ensurePrepareContext(conn driver.Conn) prepareContextFunc {
Expand Down
2 changes: 1 addition & 1 deletion query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type queryContextFunc func(ctx context.Context, query string, args []driver.Name

// nopQueryContext queries nothing.
func nopQueryContext(_ context.Context, _ string, _ []driver.NamedValue) (driver.Rows, error) {
return nil, nil
return nil, nil //nolint: nilnil
}

// skippedQueryContext always returns driver.ErrSkip.
Expand Down
Loading

0 comments on commit c00c367

Please sign in to comment.