From 0ef0e908ca06048593e8d05bb87642e2adeb8486 Mon Sep 17 00:00:00 2001 From: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com> Date: Fri, 23 Jun 2023 14:20:01 +0530 Subject: [PATCH] build: update to go1.21rc3 and make go1.19 the minimum required version Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com> --- .github/workflows/build.yml | 35 +++++++++++--------- backend/azureblob/azureblob.go | 4 +-- backend/azureblob/azureblob_internal_test.go | 4 +-- backend/azureblob/azureblob_test.go | 4 +-- backend/azureblob/azureblob_unsupported.go | 4 +-- backend/cache/cache_upload_test.go | 4 +-- fs/rc/internal.go | 5 +-- fs/versioncheck.go | 8 ++--- fstest/test_all/test_all.go | 4 +-- go.mod | 2 +- lib/debug/common.go | 6 ++++ lib/debug/go1.19.go | 14 -------- lib/debug/go1.19_compat.go | 14 -------- lib/rest/rest.go | 3 +- 14 files changed, 45 insertions(+), 66 deletions(-) delete mode 100644 lib/debug/go1.19.go delete mode 100644 lib/debug/go1.19_compat.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b855794bf..2ac54c20e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,12 +27,12 @@ jobs: strategy: fail-fast: false matrix: - job_name: ['linux', 'linux_386', 'mac_amd64', 'mac_arm64', 'windows', 'other_os', 'go1.18', 'go1.19'] + job_name: ['linux', 'linux_386', 'mac_amd64', 'mac_arm64', 'windows', 'other_os', 'go1.19', 'go1.20'] include: - job_name: linux os: ubuntu-latest - go: '1.20' + go: '1.21.0-rc.3' gotags: cmount build_flags: '-include "^linux/"' check: true @@ -43,14 +43,14 @@ jobs: - job_name: linux_386 os: ubuntu-latest - go: '1.20' + go: '1.21.0-rc.3' goarch: 386 gotags: cmount quicktest: true - job_name: mac_amd64 os: macos-11 - go: '1.20' + go: '1.21.0-rc.3' gotags: 'cmount' build_flags: '-include "^darwin/amd64" -cgo' quicktest: true @@ -59,14 +59,14 @@ jobs: - job_name: mac_arm64 os: macos-11 - go: '1.20' + go: '1.21.0-rc.3' gotags: 'cmount' build_flags: '-include "^darwin/arm64" -cgo -macos-arch arm64 -cgo-cflags=-I/usr/local/include -cgo-ldflags=-L/usr/local/lib' deploy: true - job_name: windows os: windows-latest - go: '1.20' + go: '1.21.0-rc.3' gotags: cmount cgo: '0' build_flags: '-include "^windows/"' @@ -76,23 +76,23 @@ jobs: - job_name: other_os os: ubuntu-latest - go: '1.20' + go: '1.21.0-rc.3' build_flags: '-exclude "^(windows/|darwin/|linux/)"' compile_all: true deploy: true - - job_name: go1.18 - os: ubuntu-latest - go: '1.18' - quicktest: true - racequicktest: true - - job_name: go1.19 os: ubuntu-latest go: '1.19' quicktest: true racequicktest: true + - job_name: go1.20 + os: ubuntu-latest + go: '1.20' + quicktest: true + racequicktest: true + name: ${{ matrix.job_name }} runs-on: ${{ matrix.os }} @@ -130,6 +130,11 @@ jobs: - name: Install Libraries on macOS shell: bash run: | + # https://github.com/Homebrew/brew/issues/15621#issuecomment-1619266788 + # https://github.com/orgs/Homebrew/discussions/4612#discussioncomment-6319008 + unset HOMEBREW_NO_INSTALL_FROM_API + brew untap --force homebrew/core + brew untap --force homebrew/cask brew update brew install --cask macfuse if: matrix.os == 'macos-11' @@ -239,7 +244,7 @@ jobs: - name: Install Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21.0-rc.3' check-latest: true - name: Install govulncheck @@ -264,7 +269,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21.0-rc.3' - name: Go module cache uses: actions/cache@v3 diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 149938b6e..2491efebc 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -1,5 +1,5 @@ -//go:build !plan9 && !solaris && !js && go1.18 -// +build !plan9,!solaris,!js,go1.18 +//go:build !plan9 && !solaris && !js +// +build !plan9,!solaris,!js // Package azureblob provides an interface to the Microsoft Azure blob object storage system package azureblob diff --git a/backend/azureblob/azureblob_internal_test.go b/backend/azureblob/azureblob_internal_test.go index daa3b8114..827653a80 100644 --- a/backend/azureblob/azureblob_internal_test.go +++ b/backend/azureblob/azureblob_internal_test.go @@ -1,5 +1,5 @@ -//go:build !plan9 && !solaris && !js && go1.18 -// +build !plan9,!solaris,!js,go1.18 +//go:build !plan9 && !solaris && !js +// +build !plan9,!solaris,!js package azureblob diff --git a/backend/azureblob/azureblob_test.go b/backend/azureblob/azureblob_test.go index a67b71ad6..f6122b892 100644 --- a/backend/azureblob/azureblob_test.go +++ b/backend/azureblob/azureblob_test.go @@ -1,7 +1,7 @@ // Test AzureBlob filesystem interface -//go:build !plan9 && !solaris && !js && go1.18 -// +build !plan9,!solaris,!js,go1.18 +//go:build !plan9 && !solaris && !js +// +build !plan9,!solaris,!js package azureblob diff --git a/backend/azureblob/azureblob_unsupported.go b/backend/azureblob/azureblob_unsupported.go index 08d5c4063..369d6e367 100644 --- a/backend/azureblob/azureblob_unsupported.go +++ b/backend/azureblob/azureblob_unsupported.go @@ -1,7 +1,7 @@ // Build for azureblob for unsupported platforms to stop go complaining // about "no buildable Go source files " -//go:build plan9 || solaris || js || !go1.18 -// +build plan9 solaris js !go1.18 +//go:build plan9 || solaris || js +// +build plan9 solaris js package azureblob diff --git a/backend/cache/cache_upload_test.go b/backend/cache/cache_upload_test.go index b6a2c5842..d0246740a 100644 --- a/backend/cache/cache_upload_test.go +++ b/backend/cache/cache_upload_test.go @@ -160,11 +160,11 @@ func TestInternalUploadQueueMoreFiles(t *testing.T) { minSize := 5242880 maxSize := 10485760 totalFiles := 10 - rand.Seed(time.Now().Unix()) + randInstance := rand.New(rand.NewSource(time.Now().Unix())) lastFile := "" for i := 0; i < totalFiles; i++ { - size := int64(rand.Intn(maxSize-minSize) + minSize) + size := int64(randInstance.Intn(maxSize-minSize) + minSize) testReader := runInstance.randomReader(t, size) remote := "test/" + strconv.Itoa(i) + ".bin" runInstance.writeRemoteReader(t, rootFs, remote, testReader) diff --git a/fs/rc/internal.go b/fs/rc/internal.go index 4dafbb506..e2f439a29 100644 --- a/fs/rc/internal.go +++ b/fs/rc/internal.go @@ -389,10 +389,7 @@ func rcSetSoftMemoryLimit(ctx context.Context, in Params) (out Params, err error if err != nil { return nil, err } - oldMemLimit, err := debug.SetMemoryLimit(memLimit) - if err != nil { - return nil, err - } + oldMemLimit := debug.SetMemoryLimit(memLimit) out = Params{ "existing-mem-limit": oldMemLimit, } diff --git a/fs/versioncheck.go b/fs/versioncheck.go index 7a58a4ac5..afa274c92 100644 --- a/fs/versioncheck.go +++ b/fs/versioncheck.go @@ -1,8 +1,8 @@ -//go:build !go1.18 -// +build !go1.18 +//go:build !go1.19 +// +build !go1.19 package fs -// Upgrade to Go version 1.18 to compile rclone - latest stable go +// Upgrade to Go version 1.19 to compile rclone - latest stable go // compiler recommended. -func init() { Go_version_1_18_required_for_compilation() } +func init() { Go_version_1_19_required_for_compilation() } diff --git a/fstest/test_all/test_all.go b/fstest/test_all/test_all.go index 1bf0311e0..d536b83dd 100644 --- a/fstest/test_all/test_all.go +++ b/fstest/test_all/test_all.go @@ -73,7 +73,7 @@ func main() { configfile.Install() // Seed the random number generator - rand.Seed(time.Now().UTC().UnixNano()) + randInstance := rand.New(rand.NewSource(time.Now().UTC().UnixNano())) // Filter selection if *testRemotes != "" { @@ -103,7 +103,7 @@ func main() { // Runs we will do for this test in random order runs := conf.MakeRuns() - rand.Shuffle(len(runs), runs.Swap) + randInstance.Shuffle(len(runs), runs.Swap) // Create Report report := NewReport() diff --git a/go.mod b/go.mod index 8c87c7cc7..99136dc17 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/rclone/rclone -go 1.18 +go 1.19 require ( bazil.org/fuse v0.0.0-20221209211307-2abb8038c751 diff --git a/lib/debug/common.go b/lib/debug/common.go index ab0a28da9..14ea9ddc2 100644 --- a/lib/debug/common.go +++ b/lib/debug/common.go @@ -10,3 +10,9 @@ import ( func SetGCPercent(percent int) int { return debug.SetGCPercent(percent) } + +// SetMemoryLimit calls the runtime/debug.SetMemoryLimit function to set the +// soft-memory limit. +func SetMemoryLimit(limit int64) int64 { + return debug.SetMemoryLimit(limit) +} diff --git a/lib/debug/go1.19.go b/lib/debug/go1.19.go deleted file mode 100644 index 1103f2025..000000000 --- a/lib/debug/go1.19.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build go1.19 -// +build go1.19 - -package debug - -import ( - "runtime/debug" -) - -// SetMemoryLimit calls the runtime/debug.SetMemoryLimit function to set the -// soft-memory limit. -func SetMemoryLimit(limit int64) (int64, error) { - return debug.SetMemoryLimit(limit), nil -} diff --git a/lib/debug/go1.19_compat.go b/lib/debug/go1.19_compat.go deleted file mode 100644 index e4ccbc695..000000000 --- a/lib/debug/go1.19_compat.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build !go1.19 -// +build !go1.19 - -package debug - -import ( - "fmt" - "runtime" -) - -// SetMemoryLimit is a no-op on Go version < 1.19. -func SetMemoryLimit(limit int64) (int64, error) { - return limit, fmt.Errorf("not implemented on Go version below 1.19: %s", runtime.Version()) -} diff --git a/lib/rest/rest.go b/lib/rest/rest.go index f248d441d..c4fb51b6a 100644 --- a/lib/rest/rest.go +++ b/lib/rest/rest.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "mime/multipart" "net/http" "net/url" @@ -163,7 +162,7 @@ const drainLimit = 10 * 1024 * 1024 // drainAndClose discards up to drainLimit bytes from r and closes // it. Any errors from the Read or Close are returned. func drainAndClose(r io.ReadCloser) (err error) { - _, readErr := io.CopyN(ioutil.Discard, r, drainLimit) + _, readErr := io.CopyN(io.Discard, r, drainLimit) if readErr == io.EOF { readErr = nil }