Skip to content

Commit

Permalink
zapslog: Delete x/exp-based implementation
Browse files Browse the repository at this point in the history
Deletes the implementation of slog.Handler based on
golang.org/x/exp/slog.
Maintaining two implementations doesn't serve much value here.

Remaining files have been renamed to better match their contents:

- handler.go holds the slog.Handler
- handler_test.go tests that
- example_test.go contains example tests

Files that remain are still tagged with `go1.21`
so they're only visible to Go 1.21 or newer.

This way, `go test` in this directory with Go 1.20 will not fail:

```
% GOTOOLCHAIN=go1.20 go test -v
?       go.uber.org/zap/exp/zapslog     [no test files]
```

Resolves uber-go#1337
  • Loading branch information
abhinav committed Aug 23, 2023
1 parent 75a5534 commit 2652f05
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 322 deletions.
3 changes: 1 addition & 2 deletions exp/zapslog/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
// Package zapslog provides an implementation of slog.Handler which writes to
// the supplied zapcore.Core.
//
// For versions of Go before 1.21, this package uses golang.org/x/exp/slog.
// For Go 1.21 or newer, this package uses the standard log/slog package.
// Use of this package requires at least Go 1.21.
package zapslog // import "go.uber.org/zap/exp/zapslog"
79 changes: 0 additions & 79 deletions exp/zapslog/example_pre_go121_test.go

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAddSource(t *testing.T) {
entry := logs.AllUntimed()[0]
r.Equal("msg", entry.Message, "Unexpected message")
r.Regexp(
`/slog_go121_test.go:\d+$`,
`/handler_test.go:\d+$`,
entry.Caller.String(),
"Unexpected caller annotation.",
)
Expand Down
190 changes: 0 additions & 190 deletions exp/zapslog/slog_pre_go121.go

This file was deleted.

50 changes: 0 additions & 50 deletions exp/zapslog/slog_pre_go121_test.go

This file was deleted.

0 comments on commit 2652f05

Please sign in to comment.