Skip to content

Commit

Permalink
Use Go 1.19 / Remove deprecated API usage (#352)
Browse files Browse the repository at this point in the history
Go 1.19 is out. Let's use it in the CI.

Also, this updates staticcheck version and removes deprecated API usage.
  • Loading branch information
sywhang authored Aug 3, 2022
1 parent 7398ffb commit 50965fd
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 258 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.17.x", "1.18.x"]
go: ["1.17.x", "1.18.x", "1.19.x"]
include:
- go: 1.18.x
- go: 1.19.x
latest: true

steps:
Expand Down
33 changes: 18 additions & 15 deletions decorate.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,32 @@ func (c *Container) Decorate(decorator interface{}, opts ...DecorateOption) erro
// Scope, or completely replace it with a new object.
//
// For example,
// s.Decorate(func(log *zap.Logger) *zap.Logger {
// return log.Named("myapp")
// })
//
// s.Decorate(func(log *zap.Logger) *zap.Logger {
// return log.Named("myapp")
// })
//
// This takes in a value, augments it with a name, and returns a replacement for it. Functions
// in the Scope's dependency graph that use *zap.Logger will now use the *zap.Logger
// returned by this decorator.
//
// A decorator can also take in multiple parameters and replace one of them:
// s.Decorate(func(log *zap.Logger, cfg *Config) *zap.Logger {
// return log.Named(cfg.Name)
// })
//
// s.Decorate(func(log *zap.Logger, cfg *Config) *zap.Logger {
// return log.Named(cfg.Name)
// })
//
// Or replace a subset of them:
// s.Decorate(func(
// log *zap.Logger,
// cfg *Config,
// scope metrics.Scope
// ) (*zap.Logger, metrics.Scope) {
// log = log.Named(cfg.Name)
// scope = scope.With(metrics.Tag("service", cfg.Name))
// return log, scope
// })
//
// s.Decorate(func(
// log *zap.Logger,
// cfg *Config,
// scope metrics.Scope
// ) (*zap.Logger, metrics.Scope) {
// log = log.Named(cfg.Name)
// scope = scope.With(metrics.Tag("service", cfg.Name))
// return log, scope
// })
//
// Decorating a Scope affects all the child scopes of this Scope.
//
Expand Down
5 changes: 2 additions & 3 deletions dig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"reflect"
Expand Down Expand Up @@ -165,7 +164,7 @@ func TestEndToEndSuccess(t *testing.T) {
c.RequireProvide(func() contents { return "hello world" })

c.RequireInvoke(func(buff *bytes.Buffer) {
out, err := ioutil.ReadAll(buff)
out, err := io.ReadAll(buff)
require.NoError(t, err, "read from buffer failed")
require.Equal(t, "hello world", string(out), "contents don't match")
})
Expand Down Expand Up @@ -656,7 +655,7 @@ func TestEndToEndSuccess(t *testing.T) {
c.RequireInvoke(
func(s fmt.Stringer, r io.Reader) {
require.Equal(t, "foo", s.String(), "invoke got new buffer")
got, err := ioutil.ReadAll(r)
got, err := io.ReadAll(r)
assert.NoError(t, err, "failed to read from reader")
require.Equal(t, "foo", string(got), "invoke got new buffer")
})
Expand Down
Loading

0 comments on commit 50965fd

Please sign in to comment.