在Visual Studio Code for Go中自动完成括号

问题描述 投票:1回答:1

使用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设置有某种关系?有办法解决这个问题吗?

go visual-studio-code
1个回答
1
投票

在您的VSCode设置(JSON)中添加以下行;

"go.useCodeSnippetsOnFunctionSuggest": true

或者,如果您将首选项/设置视为UI版本,请搜索useCodeSnippetsOnFunctionSuggest并将其设置为true。这将

  • 将括号添加到函数名称的尾部。
  • 使用参数签名完成功能建议,包括变量类型。

go.useCodeSnippetsOnFunctionSuggestWithoutType的设置也是如此,但省略了变量类型。


您需要安装Visual Studio Code(Microsoft维护)Go扩展安装which can be found here.

© www.soinside.com 2019 - 2024. All rights reserved.