From f2015f14dd215ad97bd4fbe048e087945ec0223d Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Wed, 25 May 2022 11:44:07 -0400 Subject: [PATCH] Require Go 1.17 for module (#111) Require Go 1.17 for the module and update all scripts to use the "go install pkg@version" format for any tool installs. Remove appveyor config. Windows testing happens on Jenkins. --- .appveyor.yml | 61 ------------------------- .ci/Jenkinsfile | 7 ++- .ci/scripts/check_format.go | 4 +- .ci/scripts/check_lint.go | 4 +- .ci/scripts/test.bat | 6 +-- .ci/scripts/test.sh | 4 +- CHANGELOG.md | 2 + Makefile | 4 +- go.mod | 7 ++- providers/aix/boottime_test.go | 1 + providers/aix/defs_aix.go | 1 + providers/darwin/arch_darwin.go | 1 + providers/darwin/boottime_darwin.go | 1 + providers/darwin/defs_darwin.go | 1 + providers/darwin/host_darwin.go | 1 + providers/darwin/kernel_darwin.go | 1 + providers/darwin/machineid_darwin.go | 1 + providers/darwin/memory_darwin.go | 1 + providers/darwin/process_darwin.go | 1 + providers/darwin/process_darwin_test.go | 1 + providers/darwin/syscall_darwin.go | 1 + providers/linux/os_test.go | 1 + 22 files changed, 32 insertions(+), 80 deletions(-) delete mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index cd78f767..00000000 --- a/.appveyor.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Version format -version: "{build}" - -image: Visual Studio 2015 - -# Environment variables -environment: - GOPATH: c:\gopath - GO111MODULE: on - GVM_GO_VERSION: 1.12.4 - GVM_DL: https://github.com/andrewkroh/gvm/releases/download/v0.2.0/gvm-windows-amd64.exe - -# Custom clone folder (variables are not expanded here). -clone_folder: c:\gopath\src\github.com\elastic\go-sysinfo - -# Cache mingw install until appveyor.yml is modified. -cache: - - C:\ProgramData\chocolatey\bin -> .appveyor.yml - - C:\ProgramData\chocolatey\lib -> .appveyor.yml - - C:\Users\appveyor\.gvm -> .appveyor.yml - - C:\Windows\System32\gvm.exe -> .appveyor.yml - -# Scripts that run after cloning repository -install: - - ps: >- - if(!(Test-Path "C:\Windows\System32\gvm.exe")) { - wget "$env:GVM_DL" -Outfile C:\Windows\System32\gvm.exe - } - - ps: gvm --format=powershell "$env:GVM_GO_VERSION" | Invoke-Expression - # AppVeyor has MinGW64. Make sure it's on the PATH. - - set PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1;%GOROOT%\bin;%PATH% - - set PATH=%GOPATH%\bin;%PATH% - - go version - - go env - - cmd /C "set ""GO111MODULE=off"" && go get github.com/elastic/go-licenser" - - python --version - -before_build: - - go mod verify - - go-licenser -d - - go run .ci/scripts/check_format.go - - go run .ci/scripts/check_lint.go - -build_script: - # Compile - - appveyor AddCompilationMessage "Starting Compile" - - cd c:\gopath\src\github.com\elastic\go-sysinfo - - go build - - appveyor AddCompilationMessage "Compile Success" - -test_script: - # Unit tests - - ps: Add-AppveyorTest "Unit Tests" -Outcome Running - - go test -v ./... - - ps: Update-AppveyorTest "Unit Tests" -Outcome Passed - -# To disable deployment -deploy: off - -# Notifications should only be setup using the AppVeyor UI so that -# forks can be created without inheriting the settings. diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 2752fe66..0c090332 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -9,7 +9,6 @@ pipeline { BASE_DIR = "src/github.com/elastic/${env.REPO}" JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba" PIPELINE_LOG_LEVEL = 'INFO' - GO111MODULE = 'on' } options { timeout(time: 1, unit: 'HOURS') @@ -38,7 +37,7 @@ pipeline { axes { axis { name 'GO_VERSION' - values '1.12.17', '1.16' + values '1.17.10', '1.18.2' } axis { name 'PLATFORM' @@ -49,7 +48,7 @@ pipeline { exclude { axis { name 'GO_VERSION' - values '1.12.17' + values '1.17.10' } axis { name 'PLATFORM' @@ -59,7 +58,7 @@ pipeline { exclude { axis { name 'GO_VERSION' - values '1.16' + values '1.18.2' } axis { name 'PLATFORM' diff --git a/.ci/scripts/check_format.go b/.ci/scripts/check_format.go index b417da99..5a234a10 100644 --- a/.ci/scripts/check_format.go +++ b/.ci/scripts/check_format.go @@ -41,9 +41,7 @@ func main() { paths = flag.Args() } - goGet := exec.Command("go", "get", "-u", "golang.org/x/tools/cmd/goimports") - goGet.Env = os.Environ() - goGet.Env = append(goGet.Env, "GO111MODULE=off") + goGet := exec.Command("go", "install", "golang.org/x/tools/cmd/goimports@latest") out, err := goGet.Output() if err != nil { log.Fatalf("failed to %v: %v", strings.Join(goGet.Args, " "), err) diff --git a/.ci/scripts/check_lint.go b/.ci/scripts/check_lint.go index 781cfc18..b2100491 100644 --- a/.ci/scripts/check_lint.go +++ b/.ci/scripts/check_lint.go @@ -40,9 +40,7 @@ func main() { log.SetFlags(0) flag.Parse() - goGet := exec.Command("go", "get", "-u", "golang.org/x/lint/golint") - goGet.Env = os.Environ() - goGet.Env = append(goGet.Env, "GO111MODULE=off") + goGet := exec.Command("go", "install", "golang.org/x/lint/golint@latest") out, err := goGet.Output() if err != nil { log.Fatalf("failed to %v: %v", strings.Join(goGet.Args, " "), err) diff --git a/.ci/scripts/test.bat b/.ci/scripts/test.bat index 9a2770f2..08d201ee 100755 --- a/.ci/scripts/test.bat +++ b/.ci/scripts/test.bat @@ -1,6 +1,4 @@ -SET GO111MODULE=off -go get -u github.com/elastic/go-licenser -SET GO111MODULE=on +go install github.com/elastic/go-licenser@latest go mod verify go-licenser -d @@ -11,5 +9,5 @@ mkdir -p build SET OUT_FILE=build\output-report.out go test "./..." -v > %OUT_FILE% | type %OUT_FILE% -go get -v -u github.com/jstemmer/go-junit-report +go install github.com/jstemmer/go-junit-report@latest go-junit-report > build\junit-%GO_VERSION%.xml < %OUT_FILE% diff --git a/.ci/scripts/test.sh b/.ci/scripts/test.sh index 09d79acc..9c7bf562 100755 --- a/.ci/scripts/test.sh +++ b/.ci/scripts/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euxo pipefail -GO111MODULE=off go get -u github.com/elastic/go-licenser +go install github.com/elastic/go-licenser@latest go mod verify go-licenser -d @@ -14,7 +14,7 @@ export OUT_FILE="build/test-report.out" mkdir -p build go test "./..." -v 2>&1 | tee ${OUT_FILE} status=$? -go get -v -u github.com/jstemmer/go-junit-report +go install github.com/jstemmer/go-junit-report@latest go-junit-report > "build/junit-${GO_VERSION}.xml" < ${OUT_FILE} exit ${status} diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bb2a20d..2f8106de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Updated module to require Go 1.17. [#111](https://github.com/elastic/go-sysinfo/pull/111) + ### Deprecated ### Removed diff --git a/Makefile b/Makefile index 0f69ebf3..9d3ea5c7 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ imports: $(GOPATH)/bin/goimports $(GOPATH)/bin/go-licenser: @echo "go-licenser missing, installing" - GO111MODULE=off go get -u github.com/elastic/go-licenser + go install github.com/elastic/go-licenser@latest $(GOPATH)/bin/gofumpt: @echo "gofumpt missing, installing" @@ -26,4 +26,4 @@ $(GOPATH)/bin/gofumpt: $(GOPATH)/bin/goimports: @echo "goimports missing, installing" - GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports \ No newline at end of file + go install golang.org/x/tools/cmd/goimports@latest diff --git a/go.mod b/go.mod index cd78dc57..927b9531 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/elastic/go-sysinfo +go 1.17 + require ( github.com/elastic/go-windows v1.0.0 github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 @@ -10,4 +12,7 @@ require ( howett.net/plist v0.0.0-20181124034731-591f970eefbb ) -go 1.13 +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect +) diff --git a/providers/aix/boottime_test.go b/providers/aix/boottime_test.go index a00f09b0..c60bc415 100644 --- a/providers/aix/boottime_test.go +++ b/providers/aix/boottime_test.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build aix // +build aix package aix diff --git a/providers/aix/defs_aix.go b/providers/aix/defs_aix.go index 2178ae46..dc5bdbab 100644 --- a/providers/aix/defs_aix.go +++ b/providers/aix/defs_aix.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build ignore // +build ignore package aix diff --git a/providers/darwin/arch_darwin.go b/providers/darwin/arch_darwin.go index c6e2c39f..7236ce64 100644 --- a/providers/darwin/arch_darwin.go +++ b/providers/darwin/arch_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/darwin/boottime_darwin.go b/providers/darwin/boottime_darwin.go index 26ee2fab..cf3a5b3c 100644 --- a/providers/darwin/boottime_darwin.go +++ b/providers/darwin/boottime_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/darwin/defs_darwin.go b/providers/darwin/defs_darwin.go index 1ca06c63..bcc1a17a 100644 --- a/providers/darwin/defs_darwin.go +++ b/providers/darwin/defs_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build ignore // +build ignore package darwin diff --git a/providers/darwin/host_darwin.go b/providers/darwin/host_darwin.go index e83c5ac1..73d2391c 100644 --- a/providers/darwin/host_darwin.go +++ b/providers/darwin/host_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/darwin/kernel_darwin.go b/providers/darwin/kernel_darwin.go index 1d133696..7d574161 100644 --- a/providers/darwin/kernel_darwin.go +++ b/providers/darwin/kernel_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build !386 // +build !386 package darwin diff --git a/providers/darwin/machineid_darwin.go b/providers/darwin/machineid_darwin.go index adfeb7df..90c5becb 100644 --- a/providers/darwin/machineid_darwin.go +++ b/providers/darwin/machineid_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/darwin/memory_darwin.go b/providers/darwin/memory_darwin.go index c069fe1a..c147b818 100644 --- a/providers/darwin/memory_darwin.go +++ b/providers/darwin/memory_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/darwin/process_darwin.go b/providers/darwin/process_darwin.go index 102363d7..f5782d80 100644 --- a/providers/darwin/process_darwin.go +++ b/providers/darwin/process_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/darwin/process_darwin_test.go b/providers/darwin/process_darwin_test.go index b23b251b..b1ba0f0c 100644 --- a/providers/darwin/process_darwin_test.go +++ b/providers/darwin/process_darwin_test.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/darwin/syscall_darwin.go b/providers/darwin/syscall_darwin.go index 1c2c8a87..52b1dab6 100644 --- a/providers/darwin/syscall_darwin.go +++ b/providers/darwin/syscall_darwin.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build (amd64 && cgo) || (arm64 && cgo) // +build amd64,cgo arm64,cgo package darwin diff --git a/providers/linux/os_test.go b/providers/linux/os_test.go index 96a327ab..bff5f9c5 100644 --- a/providers/linux/os_test.go +++ b/providers/linux/os_test.go @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +//go:build !windows // +build !windows package linux