How to set vscode format golang code on save?

You should install this plugin: https://github.com/golang/vscode-go. One of the options is to set "auto format" on save: go.formatOnSave": false. It uses the Golang tooling for formatting.


From my visual code version, i cannot use config go.formatOnSave": false.

Then I can turn them off in settings as below:

  • Build (Turn off using go.buildOnSave setting)
  • Lint (Turn off using go.lintOnSave setting)
  • Vet (Turn off using go.vetOnSave setting)
  • Format (Turn off by adding the below in your settings):
    "[go]": {
        "editor.formatOnSave": false 
    }