Inline endings in go-language source files using vim and git on MS-Windows
Situation
I am writing language applications on Windows 10. I am using vim to edit source files. I am using git for version control.
The go language comes with some unusually rigid recipes for formatting a source file. I decided that my life would be easier if I agree with this.
Problem
the command go fmt
is useful for sorting imports, aligning columns and other things. I tend to use it before registration and at other times.
The command go fmt
changes line endings to lf
. This triggers both and to issue warnings. git
vim
My decision?
Moved to "Answer" after 3 months because no other answers came up, and it is probably better for other people with a similar problem to see in the search results that this question has 1 answer, not 0 Answers
My question.
Is my solution for the final line ending optimal or am I missing something that might bite me later?
source to share
My decision.
To address the warnings, I've tweaked vim and git to work the way golang likes it.
git
The following command stops git from trying to do what is usually right: standard end-lines in the repo, platform-end-of-line in every developer working directory, convert if necessary.
git config core.autocrlf false
Now git won't change lf
to crlf
on checkout or pale about line ends.
VIM
IN _vimrc
au FileType go setl ts=3 sw=3 nowrap nu syntax=go ruler fileformat=unix
Seems to fileformat=unix
support vim complaints about strings that are not native to the platform.
Footnote
3 months after publication of the above question, I did not face any disadvantages or problems - at least, not the way I use go
, vim
and git
.
source to share