go / geany:配置构建命令

go / geany:配置构建命令

问题描述:

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.

使用go的旧版本,我可以在geany中将build命令配置为 p> 去安装“%d” code> pre>

但是似乎在Go1中您不能提供去安装 code>的绝对路径 p>

所以我想有一条命令使我在geany中运行 p>

 去安装mypackagename 
  code>   pre> 
 
 

当我的编辑文件为 p>

  /some/path/to/my/project/go/src/mypackagename/editedfile.go  
  code>  pre> 
 
 

我可以在设置中输入哪些内容来获取该信息? p>

请考虑我是linux新手,并且 可能存在使用标准Shell命令组合的简单解决方案。 p> div>

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.

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.

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

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.