Go编程语言,请帮我设置Eclipse、Vim或文本编辑器。

huangapple go评论91阅读模式
英文:

Go programing language please help me set up eclipse or vim or text editor

问题

我开始学习Go编程语言。我已经安装了Zeus和Eclipse/Goclipse。(我喜欢文本编辑器,但是我没有找到任何关于如何插入Go并进行编译的说明)。
现在,在Eclipse上运行一个基本的“hello world”程序时,我得到了以下错误信息:
“可执行源文件必须在'cmd'文件夹中”。

  1. GOROOT设置为c:\Go\
  2. GOOS设置为windows
  3. GOARCH设置为386(我忘记了我的系统,我有32位的Windows)
  4. Go工具路径(go)设置为自动“c:\go\bin\go.exe”
  5. Go格式化程序路径设置为自动(gofmt)“c:\go\bin\gofmt.exe”
  6. Go文档生成器路径(godoc)设置为自动“c:\go\bin\godoc.exe”
  7. 最后,GOPATH为空。

我按照这里的说明进行操作:http://code.google.com/p/goclipse/wiki/InstallationInstructions 和这里的说明:http://code.google.com/p/goclipse/wiki/GettingStarted。

现在,在第二个链接中,它说在资源管理器窗口中有一个“cmd”文件夹,但是我没有找到“cmd”,只有bin、pkg和src文件夹。如果你能看出我为什么会出现这个错误代码,我将非常感激并提前非常感谢你。如果有人能帮助我设置Vim或其他文本编辑器以便与Go一起使用,我也可以尝试这种方法。另外,我忘记了一件事,就像苏格拉底说的那样,我一无所知,哈哈,所以如果你能一步一步地告诉我如何修复,我会很自豪地成为一个新手。
感谢阅读并对长篇文字表示抱歉,因为我想提供尽可能多的细节。
Mar,
再次感谢。

英文:

I am starting to learn go programing language. I have installed zeus, and eclipse/goclipse. (I like text editor, however i did not find any instructions to plug in with go and compile it).
Now, on eclipse I ran a basic hello world and I am getting this:
"Executable source files must be in the 'cmd' folder"

  1. GOROOT set on c:\Go\
  2. GOOS set on windows,
  3. GOARCH set on 386 (I forgot my system, I have windows 32bit)
  4. Go tool path (go) set on auto "c:\go\bin\go.exe"
  5. Go formatter path set on auto
  6. (gofmt)auto "c:\go\bin\gofmt.exe"
  7. and Go documentor path (godoc) set on auto "c:\go\bin\godoc.exe"
  8. finally the GOPATH is empty.

I was following instructions on here http://code.google.com/p/goclipse/wiki/InstallationInstructions and here http://code.google.com/p/goclipse/wiki/GettingStarted.

Now, on the second link says cmd on the explorer window, there is no "cmd" there is bin, pkg, and src. If you can see why i have the error code, i appreciated a million and thank you veeery much in advance. If anyone can help me set up either vim, or text editor to use with go i can go that route as well. Also, i forgot one more thing, like Socrates says, i know nothing hehe so if you could tell me step at a time to fix as i am proud to be noob.
Thanks for reading and sorry about the long text because i wanted to give as much detail as possible.
Mar,
Thanks, again.

答案1

得分: 1

我不确定Goclipse项目的状态,因为我不使用它,但我建议首先尝试从命令提示符编译的基础知识。这将确保您实际上已经使其工作。给出的Goclipse的说明似乎已经过时,因为不再需要cmd。这可能只是Eclipse+Goclipse项目结构中的内部内容。

免责声明:我在OSX/Linux上工作。这个Windows的建议是我脑海中的想法

如果您已经将系统环境变量设置为您提到的路径,那么从命令提示符中,您应该能够成功运行go命令。

如果您在hello.go测试文件的位置使用cd命令,然后您应该能够运行:
go build hello.go,并在相同位置得到一个名为hello的可执行文件。这是构建单个文件的第一步。

GOPATH允许您设置一个位置,Go应该在其中搜索以找到包。该位置下应该有一个src目录和一个pkg目录。您的项目将位于src下,pkg是安装包的位置。bin是可选的,因为您可以使用GOBIN或运行go build -o /path/to/bin/hello hello.go命令的-o标志将可执行文件定向到任何位置。

一个通用的GOPATH结构可能如下所示:

projects/
  src/
    hello/
      hello.go
  pkg/

然后,您可以设置GOPATH=/path/to/projects,并可以通过以下方式从任何位置构建:
go build -o /path/to/bin/hello hello

另一种替代Eclipse的方法是使用SublimeText2,我发现它非常好用,而且它和Eclipse一样跨平台。它还有一个包管理器可以安装插件,有一个很棒的Go插件叫做GoSublime

英文:

I am not sure what the project state of Goclipse really is, since I don't use it, but I would suggest first and foremost trying the basics of compiling from the command prompt. This will ensure you actually have it working. The instructions given for Goclipse seem old as cmd is not required anymore. That may just be something internal for the project structure in Eclipse+Goclipse.

Disclaimer: I work in OSX/Linux. This advise for windows is off the top of my head

If you have already set your system environment variables to the paths you mentioned, then from the command prompt, you should successfully be able to run the go command.

If you cd in the location of your hello.go test file, you should then be able to run:
go build hello.go, and have a resulting hello executable in the same location. That is the first step to building a single file.

GOPATH allows you to set a location for which Go should search to find packages. This location should have underneath it a src directory, and a pkg directory. Your project go will live under src, and pkg is where packages get installed. Having a bin is optional since you can direct the executables to whatever location you want with GOBIN or the -o flag of running go build -o /path/to/bin/hello hello.go

A generic GOPATH structure might look like this:

projects/
  src/
    hello/
      hello.go
  pkg/

You would then be able to set GOPATH=/path/to/projects and could build from any location via:
go build -o /path/to/bin/hello hello

Another alternative to Eclipse is using SublimeText2, which I have found to be excellent, and it is cross-platform just like Eclipse. It also has a package manager to install plugins, and there is a great Go plugin called GoSublime

huangapple
  • 本文由 发表于 2012年9月13日 04:58:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/12396107.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定