atomic icon indicating copy to clipboard operation
atomic copied to clipboard

cannot upgrade package to v1.10.0

Open bogcon opened this issue 3 years ago • 3 comments

Tag v1.9.0 has support for go 1.13 (from go mod file) and in v1.10.0 it was changed to go 1.18. Isn't this a breaking change?

I want to upgrade dependencies of this project: https://github.com/actforgood/xconf and I get the following error:

go version
go version go1.16.4 darwin/amd64
go get -u
# go.uber.org/atomic
../../../go/pkg/mod/go.uber.org/[email protected]/error.go:55:12: x.v.CompareAndSwap undefined (type Value has no field or method CompareAndSwap)
../../../go/pkg/mod/go.uber.org/[email protected]/error.go:61:24: x.v.Swap undefined (type Value has no field or method Swap)
../../../go/pkg/mod/go.uber.org/[email protected]/string.go:58:12: x.v.CompareAndSwap undefined (type Value has no field or method CompareAndSwap)
../../../go/pkg/mod/go.uber.org/[email protected]/string.go:64:12: x.v.Swap undefined (type Value has no field or method Swap)
note: module requires Go 1.18

Methods Swap and CompareAndSwap from atomic.Value were introduced in go1.17.

Bellow is a Dockerfile the issue can be reproduced with. Playing with image tag from top you can see that on 1.16 error is encountered, on 1.18 everything works smoothly.

FROM golang:1.16.0-alpine3.13
# FROM golang:1.18.0-alpine3.15

RUN apk add --no-cache git

RUN git clone https://github.com/actforgood/xconf /xconf

WORKDIR /xconf

CMD ["go", "get", "go.uber.org/[email protected]"]
docker build -q -f Dockerfile -t test_upgrade .
docker run --name test_container test_upgrade
docker rm test_container
docker image rm test_upgrade

bogcon avatar Aug 28 '22 19:08 bogcon

Hey @bogcon, thanks for reporting the issue. With go.uber.org/atomic, and most of our other projects, we follow the same support policy as Go: only the current and the previous minor version are supported. With the release of Go 1.19, we only support Go 1.18 and 1.19.

That said, we understand your problem, so we can try to add back support for 1.16 by moving CompareAndSwap and Swap for Error and String into a build-tagged file.


RE: changing the go directive: No, that's not a breaking change. That doesn't change whether you can use the package in a version of Go older than what the directive says. Usage with 1.16 broke because we're using features from 1.17 without gating them with build tags.

(Internal ref: GO-1641)

abhinav avatar Sep 06 '22 16:09 abhinav

Hi @abhinav , Thanks for replying. If it doesn't worth the effort of maintaining 2 versions of some functionality based on go (version) build tags, don't do it just for me. I can handle it. Maybe it's better to leave the issue opened and see if others report it too and need it, and only then take into consideration supporting it. Note the Google Cloud Functions runtime is 1.16 based currently, for example: https://cloud.google.com/functions/docs/concepts/go-runtime .

bogcon avatar Sep 06 '22 17:09 bogcon

Ack. Looking at the implementation, it's not as straightforward. The system would have to duplicate the old CAS implementations. I'm going to elect to not do this for now, but leave the issue open as you suggested. Thanks for understanding!

abhinav avatar Sep 06 '22 17:09 abhinav