go mod vendor command leads to LF will be replaced by CRLF warning

452 views
Skip to first unread message

sitback...@gmail.com

unread,
Jan 31, 2020, 9:40:31 AM1/31/20
to golang-nuts
Hi,

I am migrating a project to go modules. I have already moved everything to the vendor folder and checked in the files.
After running go mod vendor on the clean working git tree, one of the files from a dependency, runbench.cmd, appears to
be changed according to git. I am getting the following warning:

warning: LF will be replaced by CRLF in vendor/github.com/klauspost/compress/snappy/runbench.cmd.
The file will have its original line endings in your working directory.

In the repos gitattributes file *.cmd files configured to keep their original line endings, CRLF:
*.cmd    text eol=crlf

It seems like go mod command does not take newlines into account when downloading packages.

Do you have any suggestion on how to fix this problem besides checking out the file again or adding a special
rule to gitattributes for this file?

I am using go 1.13.7 on linux/amd64.

Thank you in advance!

BR,
n

Bryan C. Mills

unread,
Feb 3, 2020, 10:19:39 AM2/3/20
to golang-nuts
`go mod vendor` copies in the files as found in the repository. It does not normalize them according to your local .gitattributes.

(In fact, the `go` command intentionally ignores attribute-based transformations when downloading modules: see https://golang.org/issue/27153.)

Reply all
Reply to author
Forward
0 new messages