使用Visual Studio Code时我注意到当我从autocomlete编写函数时,它从不用括号自动调用。例如:
fmt. //now select a function Print(a ...interface{}) from autocomplete
fmt.Print //why the parenthesehas have not been inserted automaticaly?
在VS代码中是否总是如此,或者它与VS代码的golang设置有某种关系?有办法解决这个问题吗?
在您的VSCode设置(JSON)中添加以下行;
"go.useCodeSnippetsOnFunctionSuggest": true
或者,如果您将首选项/设置视为UI版本,请搜索useCodeSnippetsOnFunctionSuggest
并将其设置为true。这将
go.useCodeSnippetsOnFunctionSuggestWithoutType
的设置也是如此,但省略了变量类型。
您需要安装Visual Studio Code(Microsoft维护)Go扩展安装which can be found here.