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

Support passing --srcdir to goimports #79

Open
dbarnett opened this issue Feb 28, 2017 · 3 comments
Open

Support passing --srcdir to goimports #79

dbarnett opened this issue Feb 28, 2017 · 3 comments

Comments

@dbarnett
Copy link
Contributor

When using goimports via our gofmt formatter as suggested in the docs, the goimports path-based inference doesn't work because we don't tell goimports about the path. It does support a --srcdir argument we could pass.

We'd have to make it conditional and detect basename(gofmt_executable) == 'goimports' or something like that because gofmt doesn't support any --srcdir arg.

@dbarnett
Copy link
Contributor Author

FWIW, goimports is more than a "formatter" and technically is not a "gofmt executable". If we run into a lot of other gotchas like this we may want to reconsider how we're hacking goimports support into codefmt.

@dbarnett
Copy link
Contributor Author

Another idea is to cd before running goimports (or whatever tool is configured in gofmt_executable), but it's a bit of a hack when there's already a --srcdir option supported and might have corner case issues (like if you're writing a new file in a subdirectory that doesn't exist yet).

@dbarnett
Copy link
Contributor Author

BTW, despite its name, --srcdir accepts the full file path including filename, not just the dir (at least since 2016). We should make it invoke goimports --srcdir=foo/bar.go instead of goimports --srcdir=foo/.

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

No branches or pull requests

1 participant