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
cmd/go: go fmt does not ignore dot files #18383
Comments
I'm not sure there is a bug here. Both programs are following their documentation. I think the open question is whether we should modify the go tool to ignore filenames that start with '.'. |
I'd be nice to have consistency, for example |
Dot files are a Unix convention and not a universal one. In general tools should not ignore them; they are just files like any other. |
@robpike, there's no need for us to be stubborn about it, though. Many of our public talks on Go extol the virtues of convention over configuration (the GOPATH layout, file naming, etc). We should accept popular existing conventions (dot files), even if we don't all totally agree with them. But consistency between "go fmt" and "gofmt" is probably a bigger argument. |
But @bradfitz, dot files are only special on Unix. The convention is not universal and Go binaries do not run only on Unix systems. Your point about consistency is of course valid, but consistent with what, and where? |
Can't we just consistently ignore the hidden files depending on the system the tool is running? Dot files on Unix, hidden file attribute on Windows. There are many support files editors generate and it is terrible having to deal with them. |
Wait, something is wrong here. The go tool, for better or worse, already ignores files whose name begins with '.' (and '_'). |
Oh, I see. So now I think the bug is that the go tool should really ignore files that start with '_' or '.' for those three cases. |
@rakyll you pretty much have to have same ignore list between platforms or else you will end up with inconsistencies with build process. If say |
@XANi I don't think we shouldn't care other than consistently ignoring dotfiles everywhere because dotfiles are portable. If you put your source in a hidden file/temp file, you are already inviting trouble because meaning of a hidden/temp file is dependent to your platform. The go tool should consider those files as invalid sources of code and ignore them all together. The go tool already uses different ignore lists via build tags. I don't think our users are having a problem with keeping the integrity of their packages. I assume ignoring hidden files is not going to create more trouble. |
@rakyll I didn't say it should care, just that relying on anything other than file name generates problems and IMO isn't even worth the effort of writing platform-specific code. It is extra code that doesn't really help anyone, as you said if someone is using hidden attribute they probably will screw themselves at some point anyway, whether go tools ignore it or not. |
CL https://golang.org/cl/45156 mentions this issue. |
Documentation specifies that gofmt ignores dotfiles but
go fmt
will still pass them as arguments to gofmt. For example (Go 1.7.3)some editors like emacs create symliks as locks for modified files like that:
.#wifitoken.go -> xani@ghroth.11692:1482232478
and that causesgo fmt
to spew errors:which could also be avoided if
go fmt
correctly ignored filesThe text was updated successfully, but these errors were encountered: