Skip to content

"go fmt" converts line endings on Windows #17167

Closed as not planned
Closed as not planned

Description

The .gitattributes in this repo is currently configured for auto, which means files are checked out with CRLF on Windows:

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

This doesn't play well with go fmt, which always converts files to LF (golang/go#16355). If you run go fmt on unchanged source files, it creates a diff in line endings:

sdk\internal\perf\testdata\perf> go fmt .
main.go
no_op_perf.go
sleep_perf.go

sdk\internal\perf\testdata\perf> git diff
warning: LF will be replaced by CRLF in sdk/internal/perf/testdata/perf/main.go.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in sdk/internal/perf/testdata/perf/no_op_perf.go.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in sdk/internal/perf/testdata/perf/sleep_perf.go.
The file will have its original line endings in your working directory 

Perhaps this repo should be configured to always checkout files with LF, even on Windows, for better compat with go fmt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Central-EngSysThis issue is owned by the Engineering System team.

Type

No type

Projects

  • Status

    🎊 Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions