[英]How can I get information about type of a Go variable
Suppose I have the following code in Go: 假设我在Go中有以下代码:
foo, bar := someFunc(baz)
I would like to create a Vim function to check type of foo
or bar
when editing a file. 我想创建一个Vim函数来在编辑文件时检查foo
或bar
类型。
Is there any tool or reliable source of information for functions from Go's packages I could use or? 我可以使用Go的软件包中的功能的工具或可靠信息源吗? As for the functions declared in the file I'm editing I was thinking about simply parsing all the functions declared in that file. 至于我正在编辑的文件中声明的函数,我正在考虑仅解析该文件中声明的所有函数。
You are looking for something like godef
您正在寻找像godef
类的godef
If the -t flag is given, the type of the expression will also be printed. 如果给定-t标志,则还将打印表达式的类型。 The -a flag causes all the public members (fields and methods) of the expression, and their location, to be printed also; -a标志使表达式的所有公共成员(字段和方法)及其位置也被打印; the -A flag prints private members too. -A标志也会打印私有成员。
I know it is being used by various vim and emacs scripts. 我知道各种vim和emacs脚本都在使用它。
The Go Oracle does this and much more. Go Oracle可以做到这一点,甚至更多。
vim-go
is a complete vim setup for Go. vim-go
是Go的完整vim设置。 It includes integration with the previously mentioned godef
(as :GoDef) and Go oracle (as :GoImplements, :GoCallees, :GoReferrers, etc) as well as other tools. 它包括与前面提到的godef
(如:GoDef)和Go oracle(如:GoImplements,:GoCallees,:GoReferrers等)以及其他工具的集成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.