diff --git a/pkg/gci/gci.go b/pkg/gci/gci.go index e84a166..fcef6c4 100644 --- a/pkg/gci/gci.go +++ b/pkg/gci/gci.go @@ -201,6 +201,10 @@ func LoadFormatGoFile(file io.FileObj, cfg config.Config) (src, dist []byte, err for _, s := range slices { i += copy(dist[i:], s) } + + // remove ^M(\r\n) from Win to Unix + dist = bytes.ReplaceAll(dist, []byte{utils.WinLinebreak}, []byte{utils.Linebreak}) + log.L().Debug(fmt.Sprintf("raw:\n%s", dist)) dist, err = goFormat.Source(dist) if err != nil { diff --git a/pkg/utils/constants.go b/pkg/utils/constants.go index 0e7cce7..2fafbc3 100644 --- a/pkg/utils/constants.go +++ b/pkg/utils/constants.go @@ -1,8 +1,9 @@ package utils const ( - Indent = '\t' - Linebreak = '\n' + Indent = '\t' + Linebreak = '\n' + WinLinebreak = '\r' Colon = ":"