如何在保存时设置vscode格式的golang代码? [英] How to set vscode format golang code on save?

查看:59
本文介绍了如何在保存时设置vscode格式的golang代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有 Go 扩展名的 vscode 来编辑 golang 源代码.每次我要格式化代码时,都必须在 linux 上按 Ctrl-Shift-i ,在上按 Shift-Alt-F Windows Ctrl-Shift-p 并键入 format .是否可以设置保存格式,也就是说,当我按 ctrl-s 时,它会使用 go.fmt (或类似方法)自动格式化代码吗?

I'm using vscode with Go extensions to edit golang source code. Each time I want to format code, I have to press Ctrl-Shift-i on linux, Shift-Alt-F on Windows, or Ctrl-Shift-p and type format. Is it possible to set format on save, that is, when I press ctrl-s, it format the code automatically using go.fmt (or something alike)?

推荐答案

您应该安装此插件: https://github.com/golang/vscode-go .选项之一是设置自动格式".保存时: go.formatOnSave":false .它使用Golang工具进行格式化.

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.

这篇关于如何在保存时设置vscode格式的golang代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆