diff --git a/.cirrus.yml b/.cirrus.yml index 33e6595..495e5e6 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,10 +1,10 @@ env: CIRRUS_CLONE_DEPTH: 1 - GO_VERSION: go1.22.2 + GO_VERSION: go1.24.0 freebsd_13_task: freebsd_instance: - image_family: freebsd-13-2 + image_family: freebsd-13-5 install_script: | pkg install -y go GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest @@ -14,7 +14,7 @@ freebsd_13_task: freebsd_14_task: freebsd_instance: - image_family: freebsd-14-0 + image_family: freebsd-14-2 install_script: | pkg install -y go GOBIN=$PWD/bin go install golang.org/dl/${GO_VERSION}@latest diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 2c6565d..1a47c8b 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -13,13 +13,13 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.0.2 with: - go-version: '1.22' - - - name: Check out code - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + go-version: '1.24' - name: Install staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e221643..59afd0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,30 +12,39 @@ jobs: build-and-test: strategy: matrix: - # Oldest supported version is 1.18, plus the latest two releases. - go-version: ['1.18', '1.21', '1.22'] - os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, macos-13, macos-14, windows-2019, windows-2022] + # Latest two supported releases. + go-version: ['1.23', '1.24'] + os: [ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm, macos-13, macos-14, macos-15, windows-2019, windows-2022] runs-on: ${{ matrix.os }} steps: + - name: Check out code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.0.2 with: go-version: ${{ matrix.go-version }} - - name: Check out code - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - - name: Check formatting - if: ${{ matrix.go-version == '1.22' && matrix.os == 'ubuntu-22.04' }} + if: ${{ matrix.go-version == '1.24' && matrix.os == 'ubuntu-24.04' }} run: diff -u <(echo -n) <(gofmt -d .) - name: Check Go modules - if: ${{ matrix.go-version == '1.22' && matrix.os == 'ubuntu-22.04' }} + if: ${{ matrix.go-version == '1.24' && matrix.os == 'ubuntu-24.04' }} run: | go mod tidy git diff --exit-code + - name: Generate + if: ${{ matrix.go-version == '1.24' }} + run: | + go generate + git diff --exit-code + + - name: Test (native) + run: go test -v ./... + - name: Build (cross-compile) if: matrix.os == 'ubuntu-22.04' run: | @@ -47,6 +56,3 @@ jobs: GOOS=openbsd go build ./... GOOS=solaris go build ./... GOOS=windows go build ./... - - - name: Test (native) - run: go test -v ./... diff --git a/go.mod b/go.mod index 68fb9b6..fecc6ab 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/tklauser/go-sysconf -go 1.18 +go 1.23.0 require ( - github.com/tklauser/numcpus v0.8.0 - golang.org/x/sys v0.19.0 + github.com/tklauser/numcpus v0.10.0 + golang.org/x/sys v0.33.0 ) diff --git a/go.sum b/go.sum index 2973ec0..6b77038 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= -github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= +github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= diff --git a/mksysconf.go b/mksysconf.go index eae4fd8..af5b8e4 100644 --- a/mksysconf.go +++ b/mksysconf.go @@ -51,19 +51,27 @@ func gensysconf(in, out, goos, goarch string) error { } func main() { - goos, goarch := runtime.GOOS, runtime.GOARCH - if goos == "illumos" { - goos = "solaris" + goos := os.Getenv("GOOS_TARGET") + if goos == "" { + goos = runtime.GOOS + if goos == "illumos" { + goos = "solaris" + } + } + goarch := os.Getenv("GOARCH_TARGET") + if goarch == "" { + goarch = runtime.GOARCH } + defs := fmt.Sprintf("sysconf_defs_%s.go", goos) if err := gensysconf(defs, "z"+defs, goos, ""); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } - vals := fmt.Sprintf("sysconf_values_%s.go", runtime.GOOS) + vals := fmt.Sprintf("sysconf_values_%s.go", goos) // sysconf variable values are GOARCH-specific, thus write per GOARCH - zvals := fmt.Sprintf("zsysconf_values_%s_%s.go", runtime.GOOS, runtime.GOARCH) + zvals := fmt.Sprintf("zsysconf_values_%s_%s.go", goos, goarch) if err := gensysconf(vals, zvals, goos, goarch); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1)