goinstall
【背景】
折腾:
【记录】go语言中通过log4go实现同时输出log信息到log文件和console
期间,以:
http://code.google.com/p/log4go/
为例,如何安装第三方包。
【折腾过程】
1.看到:
http://code.google.com/p/log4go/
中有一句安装的:
goinstall log4go.googlecode.com/hg
所以去试试:
结果我此处根本没有goinstall:
E:\Dev_Root\go\src\EmulateLoginBaidu>goinstall 'goinstall' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
2.参考:
Installing Third-Party Packages
发现,其实是
go install
所以去试试:
结果找不到:
E:\Dev_Root\go\src\EmulateLoginBaidu>go install log4go.googlecode.com/hg
can't load package: package log4go.googlecode.com/hg: cannot find package "log4go.googlecode.com/hg" in any of:
E:\dev_install_root\Go\src\pkg\log4go.googlecode.com\hg (from $GOROOT)
E:\Dev_Root\go\src\log4go.googlecode.com\hg (from $GOPATH)
3.参考:
How to install golang 3rd-party projects from download sources?
先去试试那个go get。
但是是之前,先去看看go有哪些命令:
E:\Dev_Root\go\src\EmulateLoginBaidu>go help
Go is a tool for managing Go source code.
Usage:
go command [arguments]
The commands are:
build compile packages and dependencies
clean remove object files
doc run godoc on package sources
env print Go environment information
fix run go tool fix on packages
fmt run gofmt on package sources
get download and install packages and dependencies
install compile and install packages and dependencies
list list packages
run compile and run Go program
test test packages
tool run specified go tool
version print Go version
vet run go tool vet on packages
Use "go help [command]" for more information about a command.
Additional help topics:
gopath GOPATH environment variable
packages description of package lists
remote remote import path syntax
testflag description of testing flags
testfunc description of testing functions
Use "go help [topic]" for more information about that topic.
E:\Dev_Root\go\src\EmulateLoginBaidu>
可见,get是下载并安装对应的包和依赖。
所以直接去试试:
E:\Dev_Root\go\src\EmulateLoginBaidu>go get log4go.googlecode.com/hg
package log4go.googlecode.com/hg: invalid Google Code import path: use code.google.com/p/log4go instead
4.很明显,不支持改地址,所以换用其所提示的:
code.google.com/p/log4go
结果,又出现”exec: "hg": executable file not found in %PATH%”的错误:
【已解决】go语言用go get去安装第三方包出错:exec: "hg": executable file not found in %PATH%
5.另外,安装前后,看到go官网的解释:
Download and install packages and dependencies
所以先去看看其解释:
- get默认已经包含:下载和安装;
- -d:表示只下载(不继续安装)
- -fix:下载后,解析依赖关系之前,运行fix
- -u:update
7.那就去试试直接给名字,是否可以:
E:\Dev_Root\go\src\EmulateLoginBaidu>go get log4go
package log4go: unrecognized import path "log4go"
很明显,不行。。。
8.结果还是上述的:
【已解决】go语言用go get去安装第三方包出错:exec: "hg": executable file not found in %PATH%
而解决了问题,通过hg安装了此log4go。
【总结】
此处,最终是:
windows下安装了hg: 【记录】windows下安装Mercurial的hg
再去用:
go get code.google.com/p/log4go
而成功的安装了log4go的。