Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Go 1.22 to avoid scoping bugs with closures in for loops? #7758

Closed
dmcardle opened this issue Apr 11, 2024 · 4 comments
Closed

Upgrade to Go 1.22 to avoid scoping bugs with closures in for loops? #7758

dmcardle opened this issue Apr 11, 2024 · 4 comments

Comments

@dmcardle
Copy link
Contributor

dmcardle commented Apr 11, 2024

The associated forum post URL from https://forum.rclone.org

N/a

What is the problem you are having with rclone?

Version of Go prior to 1.22 contain a footgun related to closures in for loops: https://go.dev/blog/loopvar-preview

Release notes for Go 1.22

I've run into this twice so far:

What is your rclone version (output from rclone version)

HEAD, currently 2c76800

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

N/a, the language semantics are cross-platform

Which cloud storage system are you using? (e.g. Google Drive)

N/a

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

N/a

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

N/a

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.
@Animosity022
Copy link
Collaborator

Animosity022 commented Apr 11, 2024

1.66 already has Go 1.22

https://forum.rclone.org/t/rclone-v1-66-release/44987

 rclone version
rclone v1.66.0
- os/version: darwin 14.4.1 (64 bit)
- os/kernel: 23.4.0 (arm64)
- os/type: darwin
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.22.1
- go/linking: dynamic
- go/tags: cmount

@dmcardle
Copy link
Contributor Author

Oh, I was going based on the go.mod file, which still says 1.20.

go 1.20

@dmcardle
Copy link
Contributor Author

Aha, I guess the minimum version is still 1.20, and the CI still tests go1.20. Nothing to do here. Thanks, @Animosity022!

@ncw
Copy link
Member

ncw commented Apr 12, 2024

@dmcardle we try to support current go and two previous versions, so currently that is go1.22, go1.21, go1.20.

However in two go versions time that support will look like go1.24, go1.23, go1.22 so at that point we can remove those unnecessary lines of code so you can re-open that issue then if you want!

Eg this (might not be all of them if we renamed the var too).

$ git grep -P '\b(\w+) := \1(\s|$)'
backend/azureblob/azureblob.go:         v := v
backend/b2/upload.go:           part := part // for the closure
backend/b2/upload.go:           part := part // for the closure
backend/combine/combine.go:             upstream := upstream
backend/combine/combine.go:             u := u
backend/combine/combine.go:             u := u
backend/drive/metadata.go:                              permissionID := permissionID
backend/s3/s3.go:               partNum := partNum // for closure
backend/union/policy/epff.go:           u := u // Closure
backend/union/union.go:         i := i
cmd/gitannex/gitannex_test.go:                          lineEnding := lineEnding
cmd/gitannex/gitannex_test.go:          testCase := testCase
cmd/gitannex/gitannex_test.go:          testCase := testCase
fs/config/rc.go:                name := name
fs/operations/multithread.go:           chunk := chunk
fs/operations/operations.go:                    dir := dir
fs/operations/rc.go:            copy := copy
fs/operations/rc.go:            op := op
fs/sync/rc.go:          name := name
fs/sync/sync.go:                        item := item
lib/encoder/filename/encode.go:         org := org
lib/multipart/multipart.go:             partNum := partNum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants