Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: ci

on: [push, pull_request]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -10,6 +13,10 @@ jobs:
matrix:
go-version:
- stable
- 1.25.x
- 1.24.x
- 1.23.x
- 1.22.x
- 1.21.x
- 1.20.x
- 1.19.x
Expand All @@ -20,11 +27,10 @@ jobs:
- 1.14.x
- 1.13.x
- 1.12.x
- 1.11.x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}

Expand Down
21 changes: 19 additions & 2 deletions install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
package main

import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace ioutil.TempDir with os.MkdirTemp when minimum Go version
// is raised to 1.16+. See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"
)

func TestBootstrap(t *testing.T) {
Expand All @@ -27,7 +32,19 @@ func TestBootstrap(t *testing.T) {
if runtime.GOOS == "windows" {
name += ".exe"
}
if _, err := os.Stat(filepath.Join(os.Getenv("GOPATH"), "bin", name)); err != nil {

// Use `go env GOBIN` to determine install location, as GOPATH may not be
// set in module-aware mode. Falls back to GOPATH/bin if GOBIN is empty.
binDir, err := run("go", "env", "GOBIN")
if err != nil {
t.Fatalf("failed to get GOBIN: %v", err)
}
binDir = strings.TrimSpace(binDir)
if binDir == "" {
binDir = filepath.Join(os.Getenv("GOPATH"), "bin")
}

if _, err := os.Stat(filepath.Join(binDir, name)); err != nil {
t.Fatal(err)
}
}
Expand Down
6 changes: 5 additions & 1 deletion internal/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package internal
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"runtime"
"strings"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace ioutil.Discard with io.Discard when minimum Go version
// is raised to 1.16+. See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"
)

var debug *log.Logger = log.New(ioutil.Discard, "", 0)
Expand Down
7 changes: 6 additions & 1 deletion mage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"go/build"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -22,6 +21,12 @@ import (
"text/template"
"time"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace ioutil.Discard with io.Discard and ioutil.ReadDir with
// os.ReadDir when minimum Go version is raised to 1.16+.
// See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"

"github.com/magefile/mage/internal"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/parse"
Expand Down
7 changes: 6 additions & 1 deletion mage/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"go/parser"
"go/token"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -26,6 +25,12 @@ import (
"testing"
"time"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace with os.MkdirTemp, os.WriteFile, and io.Discard when
// minimum Go version is raised to 1.16+.
// See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"

"github.com/magefile/mage/internal"
"github.com/magefile/mage/mg"
)
Expand Down
5 changes: 5 additions & 0 deletions mage/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package mage
// this template uses the "data"

// var only for tests
//
// NOTE: This template generates code that uses io/ioutil which was deprecated
// in Go 1.16. When mage's minimum Go version is raised to 1.16+, update
// _ioutil "io/ioutil" to _io "io" and _ioutil.Discard to _io.Discard.
// See: https://go.dev/doc/go1.16#ioutil
var mageMainfileTplString = `//go:build ignore
// +build ignore

Expand Down
6 changes: 5 additions & 1 deletion mage/testdata/setdir/setdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ package main

import (
"fmt"
"io/ioutil"
"strings"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace ioutil.ReadDir with os.ReadDir when minimum Go version
// is raised to 1.16+. See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"
)

func TestCurrentDir() error {
Expand Down
6 changes: 5 additions & 1 deletion mage/testdata/setworkdir/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ package main

import (
"fmt"
"io/ioutil"
"strings"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace ioutil.ReadDir with os.ReadDir when minimum Go version
// is raised to 1.16+. See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"
)

func TestWorkingDir() error {
Expand Down
6 changes: 5 additions & 1 deletion parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ import (
"go/doc"
"go/parser"
"go/token"
"io/ioutil"
"log"
"os"
"sort"
"strings"
"time"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace ioutil.Discard with io.Discard when minimum Go version
// is raised to 1.16+. See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"

"github.com/magefile/mage/internal"
)

Expand Down
8 changes: 0 additions & 8 deletions parse/testdata/subcommand_1.9.go

This file was deleted.

5 changes: 5 additions & 0 deletions parse/testdata/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ package main

import "github.com/magefile/mage/mg"

// Foo is a type alias to test that type aliases don't cause panics during
// parsing. See issue #126. Type aliases were introduced in Go 1.9, which is
// now well below the minimum supported version (1.12).
type Foo = map[string]string

type Build mg.Namespace

func (Build) Foobar() error {
Expand Down
7 changes: 6 additions & 1 deletion sh/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ package sh_test
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace with os.ReadFile, os.MkdirTemp, and os.WriteFile when
// minimum Go version is raised to 1.16+.
// See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"

"github.com/magefile/mage/sh"
)

Expand Down
6 changes: 5 additions & 1 deletion target/newer_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package target

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace with os.MkdirTemp and os.WriteFile when minimum Go
// version is raised to 1.16+. See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"
)

func TestNewestModTime(t *testing.T) {
Expand Down
6 changes: 5 additions & 1 deletion target/target_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package target

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"

// DEPRECATED: The ioutil package was deprecated in Go 1.16.
// TODO: Replace with os.MkdirTemp and os.WriteFile when minimum Go
// version is raised to 1.16+. See: https://go.dev/doc/go1.16#ioutil
"io/ioutil"
)

func TestPathMissingDest(t *testing.T) {
Expand Down