简体   繁体   English

如何获取有关Go变量类型的信息

[英]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函数来在编辑文件时检查foobar类型。

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.

相关问题 如何获取有关用户定义类型的信息? - How to get information about a User-Defined Type? 编译器如何以及在内存中的什么位置存储有关变量是什么类型的信息? - How and where in memory does the compiler store the information about what type a variable is? 如何使用括号表示法中的单个变量访问深度值? - how would I go about accessing a deep value using a single variable in bracket notation? 如何在 PHP 中以可变数量深入到多维数组中? - How can I go deep by a variable amount into a multidimensional array in PHP? 如何获取变量的类型? - How do I get the type of a variable? 如何确定C中的变量类型? - How can I determine a variable type in C? 我正在尝试链接用JavaScript或HTML代码进行的选择,并将其链接到PHP变量。 我将如何去做呢? - I am trying to link a selection made in a javascript or HTML code and link it to a PHP variable. How would I go about doing this? 一旦我获得了字符串的长度,我如何将长度数字捕获为整数变量以供在其他地方使用? - Once I have the length of a string, how do I go about capturing the length number as an integer variable for use elsewhere? 如何将js变量导入iframe - How can I get a js variable into iframe 如何获取变量的名称? - How can I get the name of a variable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM