gpt4 book ai didi

go - 名称错误 : name 'go' is not defined in sublime text 3 console

转载 作者:IT王子 更新时间:2023-10-29 02:03:31 25 4
gpt4 key购买 nike

我按照一些网页的说明安装 Sublime Text 3 并使用 package control 安装 Gosublime,然后更改其用户默认文件:

{
"env": {
"GOROOT": "d:\\go",
"GOPATH": "d:\\go\workspace",
"path: "d:\\go\\workspace\\bin"
}
}

其中d:\go是我之前下载安装的golang环境,d:\go是我建立的workspace。现在我想安装 gocode。我重新启动 Sublime Text 3,然后显示控制台。闻我进入

git get github.com/nsf/gocode

显示:

>>> go
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'go' is not defined

以下是完整的控制台日志,供引用:

GoSublime init r17.02.16-1 (0.001s)
| install margo: no
| install state: done
| sublime.version: 3126
| sublime.channel: stable
| about.ann: a17.02.16-1
| about.version: r17.02.16-1
| version: r17.02.16-1
| platform: windows-x64
| ~bin: ~\AppData\Roaming\Sublime Text 3\Packages\User\GoSublime\windows-x64\bin
| margo.exe: ~bin\gosublime.margo_r17.02.16-1_go1.8.exe (ok)
| go.exe: d:\go\bin\go.exe (ok)
| go.version: go1.8
| GOROOT: d:\go
| GOPATH: d:\go\workspace
| GOBIN: (not set) (should usually be `(not set)`)
| set.shell: []
| env.shell:
| shell.cmd: ['C:\\windows\\system32\\cmd.exe', '/C', '${CMD}']
--------------------------------

Package Control: Skipping automatic upgrade, last run at 2017-02-23 14:07:30, next run at 2017-02-23 15:07:30 or after
>>> go
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'go' is not defined
>>> go get github.com/nsf/gocode
File "<string>", line 1
go get github.com/nsf/gocode
^
SyntaxError: invalid syntax

但如果我运行 cmd.com 并输入相同的命令,它运行正常。我想念什么?

最佳答案

Sublime Text 控制台不是终端,它是一个 python shell。您可以运行 python 命令,而不是 bash (windows) 命令。

正如@keith Hall 在他的命令中所说,要运行 bash 命令,您需要一些构建系统。不过,我不认为这是解决问题的方法,因为您只想运行此命令一次,不是吗?如果是这种情况,您可能需要查看 sublimeREPL,尽管我建议简单地使用常规终端。

快速概览:

构建系统对于运行例如 python 程序非常有用。像这样一个非常简单的构建系统:

{
"cmd": ["python", "$file"]
}

触发时将运行当前打开的文件。

关于构建系统的更多信息,可能没有比 unofficial documentation 更好的资源了。

关于go - 名称错误 : name 'go' is not defined in sublime text 3 console,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42408642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com