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

x/tools/gopls: change the module path and upgrade imports within the module #41471

Open
godcong opened this issue Sep 18, 2020 · 3 comments
Open

x/tools/gopls: change the module path and upgrade imports within the module #41471

godcong opened this issue Sep 18, 2020 · 3 comments

Comments

@godcong
Copy link

@godcong godcong commented Sep 18, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.7 windows/amd64
 

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
//Has nothing to do with env

What did you do?

Now I usually modify the go.mod file.
Then modify some imports one by one.

What did you expect to see?

Sometimes a project may permanently move to a new address.
I hope go mod has any way to directly migrate my project to the new address.
Possible comannd like:

//I created a new project,use:
go mod init github.com/nameA/projectA

//When I need to migrate to a new address like nameB/projectB, to use:
go mod change github.com/nameA/projectA github.com/nameB/projectB 

Then all the imports of the project point to the new address.

What did you see instead?

Now I don't seem to see a similar function.
If there is no such feature, I hope it can be added.
If there is already have a similar functions, I hope to get some help.

@godcong godcong changed the title [Enhancement]go mod needs a way to change the package name [Enhancement]go mod can have project migration Sep 18, 2020
@godcong godcong changed the title [Enhancement]go mod can have project migration [Enhancement]hope go mod can have project migration Sep 18, 2020
@toothrot toothrot changed the title [Enhancement]hope go mod can have project migration cmd/go: rename import paths with `go mod change` Sep 18, 2020
@toothrot
Copy link
Contributor

@toothrot toothrot commented Sep 18, 2020

There are a number of tools for renaming import paths already. I am not sure that go mod is the appropriate place. If you need help finding such a tool, asking on one of the forums at http://golang.org/wiki/Questions is the best.

/cc @bcmills @jayconrod @matloob

@toothrot toothrot added this to the Backlog milestone Sep 18, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Sep 18, 2020

@marwan-at-work has a mod tool that will do this for major versions, I believe.

Such a tool would be out-of-place in cmd/go, which generally does not edit source files for you. But perhaps it would be a reasonable feature for gopls (CC @stamblerre).

@bcmills bcmills changed the title cmd/go: rename import paths with `go mod change` x/tools/gopls: change the main modules Sep 18, 2020
@bcmills bcmills changed the title x/tools/gopls: change the main modules x/tools/gopls: change the module path and upgrade imports within the module Sep 18, 2020
@godcong
Copy link
Author

@godcong godcong commented Sep 19, 2020

Yes, go mod is not necessary.
Any extension that can achieve this function will do.
Because manual modification may bring some errors caused by human operation errors.

@stamblerre stamblerre removed this from the Backlog milestone Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.