Skip to content

fileformat changed by GoFmt #595

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

Closed
cochran-at-niche opened this issue Nov 5, 2015 · 3 comments
Closed

fileformat changed by GoFmt #595

cochran-at-niche opened this issue Nov 5, 2015 · 3 comments

Comments

@cochran-at-niche
Copy link
Contributor

I am running gvim on windows 7. When I open a new .go file, I can run the following vim command in order to check the file format:

:set ff?

The result is: fileformat=dos, which I was I expect, and what I want.

If I then run the GoFmt command, like so:

:GoFmt

And again check the fileformat, it now returns fileformat=unix, which is undesirable. Furthermore, all of my line endings have changed from crlf to lf, which I do not want (git keeps complaining to me about it).

If I run :verbose set ff?, it tells me that the fileformat was Last set from ~\vimfiles\bundle\vim-go\autoload\go\fmt.go

If I revert that file (fmt.go) to a version prior to this commit: 01578fd the problem does not occur. Hence, I believe that the problem was introduced in that commit.

I should also note that I am using goimports for my GoFmt command, as established by this line in my vimrc:

let g:go_fmt_command = "goimports"

@wingyplus
Copy link
Contributor

I think it changed by gofmt not vim-go itself. see golang/go#3961 for more details.

@cochran-at-niche
Copy link
Contributor Author

I think you're correct. The commit I referenced above introduced the use of gofmt's -w option, which modifies the source file externally. Since gofmt changes all the line endings to lf, when the current buffer is reloaded it detects the fileformat as unix.

I submitted a pull-request which fixes this issue: #615

fatih added a commit that referenced this issue Nov 24, 2015
Fix issue #595 - fileformat changed by gofmt
@cochran-at-niche
Copy link
Contributor Author

The pull-request was merged in, fixing the issue. This issue can be closed.

@fatih fatih closed this as completed Nov 24, 2015
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