我对GoLang来说是全新的,所以我很有可能搞砸了我的设置.
这是我有的:
echo $GOPATH
/Users/name/Documents/Developer/Go_Workspace
Run Code Online (Sandbox Code Playgroud)
这个工作.
name$ go get -v golang.org/x/tools/cmd/oracle
Run Code Online (Sandbox Code Playgroud)
它在Go_Workspace中创建了2个子文件夹 - > src,bin,pkg.
然后,当我尝试:
go get -u golang.org/x/tools/cmd/oracle
package golang.org/x/tools/cmd/oracle: cannot find package "golang.org/x/tools/cmd/oracle" in any of:
/usr/local/go/src/golang.org/x/tools/cmd/oracle (from $GOROOT)
/Users/name/Documents/Developer/Go_Workspace/src/golang.org/x/tools/cmd/oracle (from $GOPATH)
Run Code Online (Sandbox Code Playgroud)
启用后,-v
我看到:
Fetching https://golang.org/x/tools/cmd/oracle?go-get=1
Parsing meta tags from https://golang.org/x/tools/cmd/oracle?go-get=1 (status code 200)
get "golang.org/x/tools/cmd/oracle": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/cmd/oracle?go-get=1
get "golang.org/x/tools/cmd/oracle": verifying non-authoritative meta tag
Fetching https://golang.org/x/tools?go-get=1
Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200)
golang.org/x/tools (download)
package golang.org/x/tools/cmd/oracle: cannot find …
Run Code Online (Sandbox Code Playgroud) 我按照指南进行操作,并将其安装在我的 Linux 系统上:guru -help
有效。
在将其与vs-code
指南集成时,请参阅:
https://github.com/Microsoft/vscode-go
但我不明白怎么办。有任何分步指南或任何对我有帮助的东西吗?
谢谢
我是 Go 的新手,我想知道 Goland 或带有 CLI 工具的方法是否可以列出实现给定接口的所有类型。
我找到了一个名为的工具guru
,可以列出给定类型实现的所有接口,但我无法在 CLI 中使用它。
我没看到在哪里s
定义.大师不会告诉我.我得到的只是"没有标识符的对象",但它知道k
它旁边的权利.以下是链接代码的典型代码段:
func getIndexAndRemainder(k uint64) (uint64, uint64) {
return k / s, k % s
}
Run Code Online (Sandbox Code Playgroud)
一个字母的变量名称肯定会让你更难以找到.我找了通常的嫌疑人:var s uint64
,s := ...
什么都没有.显然,它需要是某个地方定义的全球价值.
这让我有两个问题:
s
来自哪里?编辑:对于其他偶然发现此事的人.
Guru失败了,因为我没有在适当的Go工作区下检查包的源代码,方法是将git clone放在/ some/path/src下并设置GOPATH
为/ some/path.因此,虽然我认为GOPATH=. guru definition s
会起作用,GOPATH
但却被忽略了.大师可以找到,k
因为它在文件中,但它不知道如何查看其他文件.
我的grep失败的原因const
使用简单=
而不是a :=
.我将在将来贪图时记住这一点.