Go format in VSCode ========================== ###### tags: `Go` 1. Mac open visual studio code vscode 內打開```command palette``` ![](https://i.imgur.com/oJUhoNp.png) 搜尋```shell command``` 找到shell command: install code command in path ![](https://i.imgur.com/F2f2Xhr.png) 2. 修改goformat [^1] 到/usr/local/go/src/go/format/format.go 修改內容 ```go tabWidth = 4 printerMode = printer.UseSpaces ``` 3. 打開```command palette``` 搜尋![](https://i.imgur.com/QNZsvKP.png) 加入[^2][^3] ```jsonld= "go.testFlags": [ "-v" ], "github-enterprise.uri": "format", "[go]": { "editor.insertSpaces": true, "editor.snippetSuggestions": "none", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true } }, "editor.renderControlCharacters": true, "editor.renderWhitespace": "all", "go.formatTool": "goformat", ``` 完成顯示如下 ![](https://i.imgur.com/O2PMdWN.png) [^1]: [ref](https://www.cnblogs.com/hiwz/p/12642771.html) [^2]: [ref](https://www.cnblogs.com/weiweivip666/p/15972265.html) [^3]: [ref](https://code.visualstudio.com/docs/languages/go#_test)