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

Ignore shebang line #237

Open
JayeshPebble opened this issue Jul 8, 2022 · 2 comments
Open

Ignore shebang line #237

JayeshPebble opened this issue Jul 8, 2022 · 2 comments

Comments

@JayeshPebble
Copy link

We have a go file in our project that is meant to be run on the command line. We added a shebang line at the top to make it self-running, as per this blog

The problem is gofumpt converts //usr/bin/env go run to // usr/bin/env go run which makes it unrunnable from command-line

Is there a way we can ignore any lines that begin with //usr/bin/env go run or maybe exclude that file from formatting?

@mvdan
Copy link
Owner

mvdan commented Jul 13, 2022

Hm, I wasn't aware that people were actually doing this :)

I guess we can treat a comment on the first line as code (and so leave it alone) if it looks like a shebang, e.g. if it contains the string bin/. Do you reckon that would be enough?

@ALizarazoTellez
Copy link

Another way to deal with it would be to look for files that have execute permissions and their first line ends with the string go run or use some regular expression that accepts some obvious constructs.

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

No branches or pull requests

3 participants