Skip to content

Commit

Permalink
Drop go 1.20 support, update go.mod to 1.21 (#111)
Browse files Browse the repository at this point in the history
Follow-up to #110, we no longer test 1.20 so go.mod should be updated
and we can drop TODOs related to supporting 1.20.
  • Loading branch information
prashantv authored Nov 10, 2024
1 parent 3ad5434 commit 5d5291f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
as part of the Go build process.
Try this out with `go build -toolexec=errtrace pkg/to/build`.

### Changed
- Update `go` directive in go.mod to 1.21.

### Fixed
- cmd/errtrace: Don't exit with a non-zero status when `-h` is used.
- cmd/errtrace: Don't panic on imbalanced assignments inside defer blocks.
Expand Down
2 changes: 1 addition & 1 deletion assets/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module braces.dev/errtrace/assets

go 1.20
go 1.21

// This go.mod exists to avoid having the assets directory
// be shipped as part of the Go module.
2 changes: 1 addition & 1 deletion benchext/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module braces.dev/errtrace/benchext

go 1.20
go 1.21

replace braces.dev/errtrace => ../

Expand Down
2 changes: 1 addition & 1 deletion cmd/errtrace/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func testGoldenContents(t *testing.T, additionalFlags []string, file string, giv
gomod := filepath.Join(dir, "go.mod")
pkgdir := strings.TrimSuffix(filepath.Base(file), ".go")
importPath := path.Join("example.com/test", pkgdir)
if err := os.WriteFile(gomod, []byte(fmt.Sprintf("module %s\ngo 1.20\n", importPath)), 0o600); err != nil {
if err := os.WriteFile(gomod, []byte(fmt.Sprintf("module %s\ngo 1.21\n", importPath)), 0o600); err != nil {
t.Fatal(err)
}

Expand Down
13 changes: 5 additions & 8 deletions cmd/errtrace/toolexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"slices"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -83,13 +84,9 @@ func TestToolExec(t *testing.T) {
t.Fatalf("list go files in %v: %v", testProg, err)
}

// TODO: Once go.1.20 is dropped, we can use slices.DeleteFunc
nonTest := files[:0]
for _, file := range files {
if !strings.HasSuffix(file, "_test.go") {
nonTest = append(nonTest, file)
}
}
nonTest := slices.DeleteFunc(files, func(file string) bool {
return strings.HasSuffix(file, "_test.go")
})

args := []string{"-toolexec", errTraceCmd}
args = append(args, nonTest...)
Expand Down Expand Up @@ -183,7 +180,7 @@ func runGo(t testing.TB, dir string, args ...string) (stdout, stderr string) {
cmd.Stdout = &stdoutBuf
cmd.Stderr = &stderrBuf
if err := cmd.Run(); err != nil {
t.Fatalf("run failed: %v", err)
t.Fatalf("run failed: %v\n%s", err, stderrBuf.String())
}

return stdoutBuf.String(), stderrBuf.String()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module braces.dev/errtrace

go 1.20
go 1.21

0 comments on commit 5d5291f

Please sign in to comment.