配置构建命令

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

go / geany : configure build command

问题

使用旧版本的Go时,我可以在Geany中配置构建命令为

go install "%d"

但是在Go1中,似乎无法向go install提供绝对路径。

所以我想在Geany中运行以下命令:

go install mypackagename

当我的编辑文件是

/some/path/to/my/project/go/src/mypackagename/editedfile.go

我应该在设置中放什么来实现这个?

请考虑到我是一个Linux新手,可能存在使用标准shell命令组合的简单解决方案。

英文:

With an old version of go I could configure the build command in geany as

go install "%d"

But it seems that in Go1 you cannot provide to go install the absolute path.

So I'd like to have a command enabling me in geany to run

go install mypackagename

when my edited file is

/some/path/to/my/project/go/src/mypackagename/editedfile.go

What can I put in the settings to obtain that ?

Please consider that I'm a linux noob and that there may exist a trivial solution using a combination of standard shell commands.

答案1

得分: 1

我会尝试这样做:

cd "%d" && go install

它会将当前工作目录更改为geany提供的目录,并在目录更改成功后运行go install

这只在geany在shell中执行构建命令时有效。如果没有这个条件,就没有cd命令(shell会提供它作为内置命令),这个解决方案就不起作用。

那么你唯一的希望就是在geany中为构建过程配置当前工作目录。

英文:

I would try something like

cd "%d" && go install

It changes the current working directory to the directory supplied by geany and
runs go install if the directory change was successful.

This only works if geany is executing the build commands in a shell. Without that,
there's no cd (the shell provides it as an inbuilt command) and this solution won't work.

Your only hope then is, to configure the current working dir for the build process in geany.

答案2

得分: 1

使用nemo的好答案,这里有一个关于如何配置Geany用于golang的参考。

编译(F8):

go build "%f"

安装(F9):

cd "%d" && go install

测试:

cd "%d" && go test

运行(F5):

go run "%f"

请注意,Geany中的基本Go支持(包括着色)在这里描述

英文:

Using nemo's good answer, here's a reference on how Geany can be configured for golang.

Compile (F8) :

go build "%f"

Install (F9) :

cd "%d" && go install

Test :

cd "%d" && go test

Run (F5) :

go run "%f"

Note that basic Go support in Geany (including colorization) is described here.

答案3

得分: 0

我建议使用一行多命令的方式。例如:
cd /path/to/root/code/dir; go install mypackagename

英文:

I suggest a one-line multi-command thing. As in:
cd /path/to/root/code/dir; go install mypackagename

答案4

得分: -2

安装 $GOPATH/src/import-path。import-path的最后一个元素必须与该目录中源文件中的包名对应。

英文:
go install import-path

installs $GOPATH/src/import-path. Last element of import-path must correspond to the package name in source(s) in that directory.

huangapple
  • 本文由 发表于 2012年5月15日 20:58:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/10601182.html
匿名

发表评论

匿名网友

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

确定