在Visual Studio Code for Go中自动完成括号 [英] Autocompleting parentheses in Visual Studio Code for Go

查看:69
本文介绍了在Visual Studio Code for Go中自动完成括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Visual Studio Code时,我注意到当我从自动完成功能编写函数时,它永远不会使用括号自动完成功能.例如:

While using of Visual Studio Code I've noticed that when I write function from autocomlete it never autocomlete with parentheses. For example:

fmt. //now select a function Print(a ...interface{}) from autocomplete

fmt.Print //why the  parenthesehas have not been inserted automaticaly?

在VS代码中是否总是如此,还是与VS代码的golang设置相关?有办法解决这个问题吗?

Is it always so in VS code or it is somehow related to the golang setting for VS code? Is there a way how to fix that?

推荐答案

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

In your VSCode settings (JSON) add the following line;

"go.useCodeSnippetsOnFunctionSuggest":true

或者如果您正在以UI版本查看首选项/设置,请搜索 useCodeSnippetsOnFunctionSuggest 并将其设置为true.这将

Or if you are viewing your preferences/settings as the UI version, search for useCodeSnippetsOnFunctionSuggest and set it to true. This will

  • 在函数名称的结尾添加括号.
  • 带有参数签名(包括变量类型)的完整功能建议.

还有 go.useCodeSnippetsOnFunctionSuggestWithoutType 的设置,该设置相同,但是省略了变量类型.

There is also the setting of go.useCodeSnippetsOnFunctionSuggestWithoutType which does the same, but omits the variable types.

您需要安装Visual Studio Code(由Microsoft维护)Go扩展在这里找到.

You need the Visual Studio Code (Microsoft maintained) Go extension installed which can be found here.

这篇关于在Visual Studio Code for Go中自动完成括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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