我已经在我的 Eclipse 中安装了 goclipse 并创建了一个新的 go 项目。
现在这就是我所拥有的:
我有 hello.go 看起来像这样:
package main
import "fmt"
func main() {
fmt.Println("Hello")
}
然后我按下运行按钮,或者右键单击文件 hello.go,然后运行,它什么也没有。另外,bin文件夹也是空的。
然后我按下 run configurations 按钮,那里几乎是空的,只有一个项目名称。它给出了:
Given Go package not found.
这是我对 Go 的偏好:
我注意到 GOROOT 和 GOPATH 都与资源管理器中列出的不同,但是一旦我将它们更改为 C:\Go\src\pkg 或 C:\Go\src,应用和确定按钮就会被禁用。另外,我也没有 C:\Go\src\pkg 文件夹。
我可以在命令行中 go install 或 go build,但我想将 eclipse 用于另一个更大的项目。它是 windows 7,eclipse 版本是 Luna Service Release 1 (4.4.1)。谢谢。
编辑:现在我有以下配置,它工作正常: Go 安装在 c:\Go 在首选项中:GOROOT:C:\Go, GOPATH: C:\Users\Tiina\go_workspace Preferences 中的其余部分会自动填写。 helloTest 项目位于 C:\Users\Tiina\go_workspace\src\helloTest hello.go 位于 C:\Users\Tiina\go_workspace\src\helloTest\hello.go 可能是因为我从现有代码创建了一个项目,并且有一些遗留的东西,它会自动添加另一个 GOPATH,在 Preferences 中删除它。
最佳答案
如果 GOROOT指 go 的安装位置( C:\Go ),那么您需要确保:
GOPATH不同于 GOROOT (这很重要,因为 GOROOT/[src|pkg|bin] 是 Go 语言本身的文件夹,而不是您自己的资源)GOPPATH指向所有不同 Go 项目将驻留的文件夹(例如 C:\Users\yourName\Go :它定义了 workspace )GOPATH\src\myproject 中创建的请参阅“How to Write Go Code”以确保您的安装和项目来源符合预期的组织。
Now it works, but I noticed two things odd.
- First what I did: I move
helloTestfolder intoC:\Users\Tiina\go_workspace\src, so now it is atC:\Users\Tiina\go_workspace\src\helloTest.- Then I create project from existing code. Nothing else changed. Now I have two
GOPATHin explorer, one isC:\Users\Tiina\go_workspace\src, the other one isC:\Users\Tiina\go_workspace\helloTest\src.
The latter one did no exist at the beginning
我怀疑 goclipse确实是定义一个 GOPATH每个项目(或完成现有的 GOPATH )。
如果您创建或导入项目,它将定义/完成 GOPATH在 <that project/src>
如果你 hello.go 在那个 <that project/src/> 内文件夹,然后它应该按预期构建和工作。
user guide "project structure" of goclipse提及:
The project location is not part of any
GOPATHentry.
In this case the project location will implicitly be added as an entry to theGOPATH, and a Go workspace structure with thebin,pkg, andsrcdirectories will be used in the project.Note that the project's implicit
GOPATHentry will only apply to the source modules in that project. It will not be visible to other Goclipse projects (unless the entry is explicitly added to the globalGOPATH).In the
srcfolder you can create Go source files that will be compiled into a library package (and placed intopkg), or into an executable (and placed inbin)
关于eclipse - 如何在安装了 goclipse 的 Eclipse 中运行 GO 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27477855/
出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我打算为ruby脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e