Skip to content

Commit dd4463e

Browse files
authored
chore: bump minimum Go to 1.26 and adopt 1.26 features (#2920)
1 parent 325e318 commit dd4463e

21 files changed

Lines changed: 77 additions & 74 deletions

.github/renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"osvVulnerabilityAlerts": true,
1111
"postUpdateOptions": ["gomodTidy"],
1212
"constraints": {
13-
"go": "1.25.10"
13+
"go": "1.26.4"
1414
},
1515
"customManagers": [
1616
{

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
go-version: [1.25.x, 1.26.x]
24+
go-version: [1.26.x, 1.27.x]
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: 📥 Checkout
@@ -40,7 +40,7 @@ jobs:
4040
strategy:
4141
fail-fast: false
4242
matrix:
43-
go-version: [1.25.x, 1.26.x]
43+
go-version: [1.26.x, 1.27.x]
4444
platform: [ubuntu-latest, macos-latest, windows-latest]
4545
runs-on: ${{ matrix.platform }}
4646
steps:
@@ -63,7 +63,7 @@ jobs:
6363
strategy:
6464
fail-fast: false
6565
matrix:
66-
go-version: [1.25.x, 1.26.x]
66+
go-version: [1.26.x, 1.27.x]
6767
runs-on: ubuntu-latest
6868
steps:
6969
- name: 📥 Checkout

.github/workflows/release-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up Go
2121
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
2222
with:
23-
go-version: 1.26.x
23+
go-version: 1.27.x
2424

2525
- name: Run GoReleaser
2626
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Set up Go
2222
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
2323
with:
24-
go-version: 1.26.x
24+
go-version: 1.27.x
2525

2626
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2727
with:

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### 📦 Package API
6+
7+
- Bumped the minimum Go version to 1.26. Task follows Go's two-latest support
8+
window, and is now tested against 1.26 and 1.27. This only affects projects
9+
importing Task as a Go module (#2920 by @vmaerten).
10+
311
## v3.53.1 - 2026-08-18
412

513
### 🚀 Features

checksum_benchmark_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build fsbench
2-
// +build fsbench
32

43
package task_test
54

errors/error_taskfile_decode.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ type (
2525

2626
func NewTaskfileDecodeError(err error, node *yaml.Node) *TaskfileDecodeError {
2727
// If the error is already a DecodeError, return it
28-
taskfileInvalidErr := &TaskfileDecodeError{}
29-
if errors.As(err, &taskfileInvalidErr) {
28+
if taskfileInvalidErr, ok := errors.AsType[*TaskfileDecodeError](err); ok {
3029
return taskfileInvalidErr
3130
}
3231
return &TaskfileDecodeError{
@@ -45,8 +44,7 @@ func (err *TaskfileDecodeError) Error() string {
4544
fmt.Fprintln(buf, color.RedString("err: %s", err.Message))
4645
} else {
4746
// Extract the errors from the TypeError
48-
te := &yaml.TypeError{}
49-
if errors.As(err.Err, &te) {
47+
if te, ok := errors.AsType[*yaml.TypeError](err.Err); ok {
5048
if len(te.Errors) > 1 {
5149
fmt.Fprintln(buf, color.RedString("errs:"))
5250
for _, message := range te.Errors {

errors/errors.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ func As(err error, target any) bool {
6767
return errors.As(err, target)
6868
}
6969

70+
// AsType wraps the standard errors.AsType function so that we don't need to alias
71+
// that package. It returns the first error in err's tree that matches type T, and
72+
// whether such an error was found.
73+
func AsType[T error](err error) (T, bool) {
74+
return errors.AsType[T](err)
75+
}
76+
7077
// Unwrap wraps the standard errors.Unwrap function so that we don't need to alias that package.
7178
func Unwrap(err error) error {
7279
return errors.Unwrap(err)

errors/errors_task.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ func (err *TaskRunError) Code() int {
4848
}
4949

5050
func (err *TaskRunError) TaskExitCode() int {
51-
var exit interp.ExitStatus
52-
if errors.As(err.Err, &exit) {
51+
if exit, ok := errors.AsType[interp.ExitStatus](err.Err); ok {
5352
return int(exit)
5453
}
55-
var timeout *TaskTimeoutError
56-
if errors.As(err.Err, &timeout) {
54+
if _, ok := errors.AsType[*TaskTimeoutError](err.Err); ok {
5755
return TimeoutExitCode
5856
}
5957
return err.Code()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/go-task/task/v3
22

3-
go 1.25.10
3+
go 1.26.4
44

55
require (
66
charm.land/bubbles/v2 v2.1.1

0 commit comments

Comments
 (0)