Skip to content

Commit

Permalink
chore: Upgrade go.uber.org/zap/exp to v0.3.0 (to fix dependabot upgra…
Browse files Browse the repository at this point in the history
…des) (#3378)

Dependabot PRs #3306 and
#3343 want to (among other things)
upgrade go.uber.org/zap/exp from v0.2.0 to v0.3.0 . This causes a nil
pointer exception because of [this
code](https://github.com/gnolang/gno/blob/master/gno.land/pkg/log/zap.go#L74):
```
	return slog.New(zapslog.NewHandler(logger.Core(), nil))
```

The problem is that go.uber.org/zap/exp v0.2.0 has:
```
func NewHandler(core zapcore.Core, opts *HandlerOptions) *Handler
```
but v0.3.0 has:
```
func NewHandler(core zapcore.Core, opts ...HandlerOption) *Handler
```
Thus, it views the nil second argument as a nil `HandlerOption`. The fix
is to simply remove the second argument in the call to `NewHandler`.

When this is merged, we can tell dependabot to rebase the original PRs
and the CI tests should pass.

Signed-off-by: Jeff Thompson <[email protected]>
Co-authored-by: Morgan <[email protected]>
  • Loading branch information
jefft0 and thehowl authored Dec 20, 2024
1 parent 1a96739 commit 10db3b4
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ require (
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap/exp v0.2.0 // indirect
go.uber.org/zap/exp v0.3.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contribs/gnofaucet/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap/exp v0.2.0 // indirect
go.uber.org/zap/exp v0.3.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions contribs/gnofaucet/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gno.land/pkg/log/zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ func NewZapLogger(enc zapcore.Encoder, w io.Writer, level zapcore.Level, opts ..

// ZapLoggerToSlog wraps the given zap logger to an log/slog Logger
func ZapLoggerToSlog(logger *zap.Logger) *slog.Logger {
return slog.New(zapslog.NewHandler(logger.Core(), nil))
return slog.New(zapslog.NewHandler(logger.Core()))
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.29.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
go.uber.org/zap/exp v0.2.0
go.uber.org/zap/exp v0.3.0
golang.org/x/crypto v0.26.0
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/mod v0.20.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions misc/autocounterd/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10db3b4

Please sign in to comment.