Proposal: add context import path upgrade to go tool fix #17040

Closed
SamWhited opened this Issue Sep 9, 2016 · 7 comments

Projects

None yet

5 participants

@SamWhited
Contributor
SamWhited commented Sep 9, 2016 edited

It would be convenient if go tool fix had a rule (possibly off by default?) added to upgrade imports of the context package to the new version in the standard library.

Here is a CL that I'm using to upgrade my projects: https://go-review.googlesource.com/#/c/28872/

This makes the new rewrites list read as follows:

Available rewrites are:

context
        Change imports of golang.org/x/net/context to context

gotypes
        Change imports of golang.org/x/tools/go/{exact,types} to go/{constant,types}

netipv6zone
        Adapt element key to IPAddr, UDPAddr or TCPAddr composite literals.

        https://codereview.appspot.com/6849045/

printerconfig
        Add element keys to Config composite literals.

This isn't strictly the same as some of the other rewrites in the tool because the old context package is still perfectly usable, so maybe it would be best to leave this fix off by default and allow it to be manually specified.

@gopherbot

CL https://golang.org/cl/28872 mentions this issue.

@quentinmit
Contributor

You likely want to remain with the old package for quite a while to support building with Go <1.7. I think perhaps we'd want to do this a year or more from now.

@quentinmit quentinmit added this to the Go1.8Maybe milestone Sep 12, 2016
@SamWhited
Contributor
SamWhited commented Sep 12, 2016 edited

Agreed, having it off by default seems sensible, but going ahead and putting it in the tool seems like it would be nice for those who explicitly want to upgrade.

@SamWhited
Contributor
SamWhited commented Sep 12, 2016 edited

I've updated the CL to require -force context for the fix to be run (it looks like force wasn't otherwise used). Would this be an acceptible way to do it? The behavior could then be changed after the 1.8 release cycle or whenever the Go team decides it's more appropriate to be default-on.

@adg
Contributor
adg commented Sep 12, 2016
@bradfitz
Member

We still ship and use go tool fix? Flashback!

@bradfitz
Member

But yeah, SGTM. Opt-in sounds good.

@gopherbot gopherbot pushed a commit that closed this issue Sep 15, 2016
@SamWhited @bradfitz SamWhited + bradfitz cmd/fix: add golang.org/x/net/context fix
Fixes #17040

Change-Id: I3682cc0367b919084c280d7dc64746495c1d4aaa
Reviewed-on: https://go-review.googlesource.com/28872
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
22d3bf1
@gopherbot gopherbot closed this in 22d3bf1 Sep 15, 2016
@Thomasdezeeuw Thomasdezeeuw referenced this issue in grpc/grpc-go Sep 15, 2016
Open

Go 1.7 uses import "context" #711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment