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

Update "code.google.com" import paths #492

Closed
snej opened this issue Nov 6, 2014 · 2 comments
Closed

Update "code.google.com" import paths #492

snej opened this issue Nov 6, 2014 · 2 comments
Assignees
Labels

Comments

@snej
Copy link
Contributor

snej commented Nov 6, 2014

I just got this email from the golang-announce list. SG, Walrus and go-couchbase use some of these packages and should be updated.


As a prelude to the Go 1.4 release, the Go sub-repositories (go.tools, go.net, go.crypto, and so on) will be made available using custom import paths. See golang.org/s/go14subrepo for background.

This list shows the current base import paths, and their new equivalents.

code.google.com/p/go.benchmarks -> golang.org/x/benchmarks
code.google.com/p/go.blog -> golang.org/x/blog
code.google.com/p/go.crypto -> golang.org/x/crypto
code.google.com/p/go.exp -> golang.org/x/exp
code.google.com/p/go.image -> golang.org/x/image
code.google.com/p/go.mobile -> golang.org/x/mobile
code.google.com/p/go.net -> golang.org/x/net
code.google.com/p/go.sys -> golang.org/x/sys
code.google.com/p/go.talks -> golang.org/x/talks
code.google.com/p/go.text -> golang.org/x/text
code.google.com/p/go.tools -> golang.org/x/tools

The "x" in the path serves to disambiguate these external packages from the standard library.

If your code imports packages from these repositories, please prepare changes to update the import paths, and commit those changes either before or shortly after the official repositories are renamed. (These new import paths work today, but the code in those repositories has not yet been updated to use them.)

The change will be made on Sunday, November 9, 2014.

Updating

Any import path in any Go source file beginning with “code.google.com/p/go.” should change to begin with “golang.org/x/”.

On Linux, OS X, and other Unix systems, this command updates all Go source files in the current directory and all subdirectories, so running it in your GOPATH workspace root should suffice to update all your source code:

    sed -i .orig 's|"code\.google\.com/p/go\.|"golang.org/x/|' \
        $(find . -name '*.go')

Potential issues

After the change, code that uses the old import paths will not break. Instead, two copies of a given repository may be created inside your workspace.

For example, the "code.google.com/p/go.tools/go/ssa" package depends on "code.google.com/p/go.tools/go/types". After the change, these two paths will become "golang.org/x/tools/go/ssa" and "golang.org/x/tools/go/types", and the import statement in package ssa will be updated accordingly.

If your code imports the ssa package using its old path, when the import paths are changed the dependency graph will look like this:

your package -> "code.google.com/p/go.tools/go/ssa" -> "golang.org/x/tools/go/types"

If you run "go get", it will check out two copies of the go.tools repository: one under the old path, and one under the new path. If your program also contains references to "code.google.com/p/go.tools/go/types", you will end up with both copies of the go/types package (with different import paths) in the same executable.

To fix this, update the import statements in your code to use the new paths and then delete the old "src/code.google.com/p/go.*" directories from your workspace.

@adamcfraser
Copy link
Collaborator

Had a look at this today, but hit a blocker as a few of the new golang.org/x/ libraries that we use still include references to the old code.google.com/p/ equivalents, which introduced build issues when I tried to pull out the old references.

e.g.
building SG:
golang.org/x/crypto/bcrypt/bcrypt.go:11:2: cannot find package "code.google.com/p/go.crypto/blowfish"

building walrus:
src/golang.org/x/text/collate/collate.go:14:2: cannot find package "code.google.com/p/go.text/collate/colltab"
src/golang.org/x/text/collate/collate.go:15:2: cannot find package "code.google.com/p/go.text/language"
src/golang.org/x/text/collate/collate.go:16:2: cannot find package "code.google.com/p/go.text/unicode/norm"

I'll have another look Monday (after the changeover is official).

@adamcfraser
Copy link
Collaborator

Done with PR #559

@adamcfraser adamcfraser added done and removed ready labels Jan 9, 2015
@adamcfraser adamcfraser removed the done label Jan 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants