Skip to content

Commit

Permalink
Use Go 1.21 (#1111)
Browse files Browse the repository at this point in the history
This updates go.mod files to use Go 1.21.

It also updates the CI to use Go 1.20 and 1.21 to test.

Note that this specifies the minimum version required to work with Fx to
be Go 1.20 as specified in the toolchain specification
(https://go.dev/doc/toolchain).
  • Loading branch information
sywhang committed Aug 15, 2023
1 parent 3ed9d86 commit 391edcd
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
go: ["1.19.x", "1.20.x"]
go: ["1.20.x", "1.21.x"]
include:
- go: 1.20.x
- go: 1.21.x
os: "ubuntu-latest"
latest: true

Expand Down
2 changes: 1 addition & 1 deletion docs/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.uber.org/fx/docs

go 1.19
go 1.20

require (
github.com/stretchr/testify v1.8.0
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.uber.org/fx

go 1.19
go 1.20

require (
github.com/benbjohnson/clock v1.3.0
Expand Down
50 changes: 50 additions & 0 deletions internal/fxreflect/stack_120_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build !go1.21
// +build !go1.21

package fxreflect

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDeepStack(t *testing.T) {
t.Run("nest", func(t *testing.T) {
// Introduce a few frames.
frames := func() []Frame {
return func() []Frame {
return CallerStack(0, 0)
}()
}()

require.True(t, len(frames) > 3, "expected at least three frames")
for i, name := range []string{"func1.1.1", "func1.1", "func1"} {
f := frames[i]
assert.Equal(t, "go.uber.org/fx/internal/fxreflect.TestDeepStack."+name, f.Function)
assert.Contains(t, f.File, "internal/fxreflect/stack_120_test.go")
assert.NotZero(t, f.Line)
}
})
}
50 changes: 50 additions & 0 deletions internal/fxreflect/stack_121_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build go1.21
// +build go1.21

package fxreflect

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDeepStack(t *testing.T) {
t.Run("nest", func(t *testing.T) {
// Introduce a few frames.
frames := func() []Frame {
return func() []Frame {
return CallerStack(0, 0)
}()
}()

require.True(t, len(frames) > 3, "expected at least three frames")
for i, name := range []string{"func1.TestDeepStack.func1.1.func2", "func1.1", "func1"} {
f := frames[i]
assert.Equal(t, "go.uber.org/fx/internal/fxreflect.TestDeepStack."+name, f.Function)
assert.Contains(t, f.File, "internal/fxreflect/stack_121_test.go")
assert.NotZero(t, f.Line)
}
})
}
21 changes: 1 addition & 20 deletions internal/fxreflect/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,6 @@ func TestStack(t *testing.T) {
assert.NotZero(t, f.Line)
})

t.Run("default/deeper", func(t *testing.T) {
t.Parallel()

// Introduce a few frames.
frames := func() []Frame {
return func() []Frame {
return CallerStack(0, 0)
}()
}()

require.True(t, len(frames) > 3, "expected at least three frames")
for i, name := range []string{"func2.1.1", "func2.1", "func2"} {
f := frames[i]
assert.Equal(t, "go.uber.org/fx/internal/fxreflect.TestStack."+name, f.Function)
assert.Contains(t, f.File, "internal/fxreflect/stack_test.go")
assert.NotZero(t, f.Line)
}
})

t.Run("skip", func(t *testing.T) {
t.Parallel()

Expand All @@ -78,7 +59,7 @@ func TestStack(t *testing.T) {

require.NotEmpty(t, frames)
f := frames[0]
assert.Equal(t, "go.uber.org/fx/internal/fxreflect.TestStack.func3", f.Function)
assert.Equal(t, "go.uber.org/fx/internal/fxreflect.TestStack.func2", f.Function)
assert.Contains(t, f.File, "internal/fxreflect/stack_test.go")
assert.NotZero(t, f.Line)
})
Expand Down
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.uber.org/fx/tools

go 1.19
go 1.20

require (
github.com/bwplotka/mdox v0.9.0
Expand Down

0 comments on commit 391edcd

Please sign in to comment.