0

Here's the problem.

I want to format my golang files when they get saved, so I have this in my user settings (JSON) file.

    "[go]": {
        "editor.formatOnSave": true,
    },

But as a side effect, whenever I save a file that has a // +build integration tag at the very top of it, VSCode ends up adding //go:build integration to the top of the file, in addition to formatting the file.

Any clues how I can disable this behavior?

rioV8
  • 24,506
  • 3
  • 32
  • 49
rexagod
  • 39
  • 2
  • 3
    I guess that's just the way gofmt behaves. But I don't see what the problem is. gofmt does the right thing and replaces the old version with the new version of that build comment. https://stackoverflow.com/a/67937234/9208887 – The Fool Jan 19 '22 at 15:00
  • 3
    The fmt tool is changing the file to the correct go1.17 format: https://go.dev/doc/go1.17#gofmt – JimB Jan 19 '22 at 15:01
  • 3
    _"Any clues how I can disable this behavior?"_ You shouldn't. Be grateful that `gofmt` replaces your deprecated code with the new, preferred version. – icza Jan 19 '22 at 15:05

1 Answers1

1

I stand corrected that this is indeed the latest, better behavior. Thanks JimB and The Fool.

rexagod
  • 39
  • 2