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: #17840

Closed
Deathstroke72 opened this issue Nov 7, 2016 · 2 comments
Closed

x/tools/cmd/goimports: #17840

Deathstroke72 opened this issue Nov 7, 2016 · 2 comments

Comments

@Deathstroke72
Copy link

Please answer these questions before submitting your issue. Thanks!

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

1.7

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

Import using the vendor folder. I used the github.com/lib/pq library. In my code, it only references postgres in the datasource name. If I don't use _ github.com/lib/pq/library in the imports section, goimports deletes the import line for it. I don't want to have to use the _ preface.

What did you expect to see?

What did you see instead?

@bradfitz
Copy link
Contributor

bradfitz commented Nov 7, 2016

This isn't enough information for us to help you.

Please include all the relevant files, ideally in a minimal form to see the problem.

@quentinmit
Copy link
Contributor

This is WAI. goimports only preserves the import lines that are used by the rest of the file; if you want to keep an import despite not using it, you need to import it as _ (this is called a blank import). See https://golang.org/doc/effective_go.html#blank_import

@golang golang locked and limited conversation to collaborators Nov 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants