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/cmd/goimports: removes imports ending in ".git" or whatever vcs #8655

gopherbot opened this issue Sep 4, 2014 · 5 comments


Copy link

@gopherbot gopherbot commented Sep 4, 2014

by xofyarg:

What does 'go version' print?

go version go1.3.1 linux/amd64

What steps reproduce the problem?
If possible, include a link to a program on

1. use a custom git repo:
2. import "" and add some code using it, say bar.Do()
3. call goimports

What happened?

it removes the import line above

What should have happened instead?

keep the import line
Copy link

@bradfitz bradfitz commented Sep 4, 2014

Comment 1:

The final path component of your import should be the same as your package name. 
"bar.git" isn't a valid package name.
This doesn't have anything to do with the git repo being private or not.
Can you give more details? Actual minimal example, and details of what the package name
actually is?
Copy link

@gopherbot gopherbot commented Sep 4, 2014

Comment 2 by xofyarg:

If I strip the extension from the import path, then it is not go get-able. Here's a
quote from `go help importpath':
> For code hosted on other servers, import paths may either be qualified
> with the version control type, or the go tool can dynamically fetch
> the import path over https/http and discover where the code resides
> from a <meta> tag in the HTML.
> To declare the code location, an import path of the form
>         repository.vcs/path
> specifies the given repository, with or without the .vcs suffix,
> using the named version control system, and then the path inside
> that repository.  The supported version control systems are:
>         Bazaar      .bzr
>         Git         .git
>         Mercurial   .hg
>         Subversion  .svn
> For example,
>         import ""
The go get command has some popular repositories hardcoded, to support custom repo, I
need to show the repo type.
The package is in our private server(sorry, not accessable from outside), and we have
some code like this:
Copy link

@ianlancetaylor ianlancetaylor commented Sep 4, 2014

Comment 3:

Labels changed: added repo-tools.

Copy link

@dmitshur dmitshur commented Nov 22, 2014

My first guess is that it might be the regexp that matches imports doesn't take this possibility into account.

@gopherbot gopherbot added new labels Nov 22, 2014
@bradfitz bradfitz removed the new label Dec 18, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title goimports: removes imports ending in ".git" or whatever vcs x/tools/cmd/goimports: removes imports ending in ".git" or whatever vcs Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015
@rsc rsc removed the repo-tools label Apr 14, 2015
Copy link

@heschik heschik commented Nov 7, 2019

Triaging old goimports bugs: I'm pretty sure this should be fixed by now, and a quick test seems to confirm it. Please comment if you disagree.

@heschik heschik closed this Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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