-1

When I run go fmt ./... under the root directory of the project in my vscode I got different formatting results on different OS:

Windows

import (
"github.com/abc"
"gotest.tools/assert"
"testing"

)

MacOS

 import (
"testing"

"github.com/abc"
"gotest.tools/assert"

)

Is this the expected behaviour for gofmt in different OS? If so, how do I config the code formatting rules in vscode to make it consistent?

Edit: I am using the same version of Golang on both OS.

User3301
  • 95
  • 3
  • 8

1 Answers1

1

It is very likely you have different versions of gofmt on different platforms. Another option - different set of commands.

You can try to run the command like this:

go fmt -n ./...

It should print details of gofmt utility calls. You can diff outputs from different platforms.

Based on my past experience VSCode didn't seem reliable and I had to switch to GoLand.

zoonman
  • 1,116
  • 1
  • 12
  • 30