【已解决】go语言用go get去安装第三方包出错:exec: "hg": executable file not found in %PATH%

【问题】

折腾:

【记录】go语言中安装第三方包package(库)

期间,去用:

go get code.google.com/p/log4go

结果出错:

E:\Dev_Root\go\src\EmulateLoginBaidu>go get code.google.com/p/log4go
go: missing Mercurial command. See http://golang.org/s/gogetcmd
package code.google.com/p/log4go: exec: "hg": executable file not found in %PATH%

如图:

exec hg executable file not found in PATH

即:

exec: "hg": executable file not found in %PATH%

【解决过程】

1.很明显,是在windows的cmd中,找不到hg。

而对于hg,如果是cygwin等环境,那肯定没问题,但是此处是cmd,所以没法用hg。

2.参考:

package code.google.com/p/go.example/hello: exec: “hg”: executable file not found in %PATH%. How to get remote golang packages?

也是让去安装hg。

3.所以就需要去另外在windows中安装hg:

【记录】windows下安装Mercurial的hg

4.安装完毕,就可以继续去试试了:

E:\Dev_Root\go\src\EmulateLoginBaidu>go get code.google.com/p/log4go

E:\Dev_Root\go\src\EmulateLoginBaidu>

结果就是:

没有消息,就是最好的消息

即:安装成功了,无任何错误信息。

5.那就去确认一下:

E:\Dev_Root\go\src\EmulateLoginBaidu>go get code.google.com/p/log4go

E:\Dev_Root\go\src\EmulateLoginBaidu>ls
EmulateLoginBaidu.go  EmulateLoginBaidu.go.bak  EmulateLoginBaidu.log  EmulateLoginBaidu.log.bak

E:\Dev_Root\go\src\EmulateLoginBaidu>ls ../../src
EmulateLoginBaidu  EmulateLoginBaidu_2013-09-18_office_tryHandleCookie.7z  code.google.com  common_func_test  hello

E:\Dev_Root\go\src\EmulateLoginBaidu>cd
E:\Dev_Root\go\src\EmulateLoginBaidu

E:\Dev_Root\go\src\EmulateLoginBaidu>ls
EmulateLoginBaidu.go  EmulateLoginBaidu.go.bak  EmulateLoginBaidu.log  EmulateLoginBaidu.log.bak

E:\Dev_Root\go\src\EmulateLoginBaidu>cd ..

E:\Dev_Root\go\src>ls
EmulateLoginBaidu  EmulateLoginBaidu_2013-09-18_office_tryHandleCookie.7z  code.google.com  common_func_test  hello

E:\Dev_Root\go\src>cd code.google.com

E:\Dev_Root\go\src\code.google.com>ls
p

E:\Dev_Root\go\src\code.google.com>cd p

E:\Dev_Root\go\src\code.google.com\p>ls
log4go

E:\Dev_Root\go\src\code.google.com\p>cd log4go

E:\Dev_Root\go\src\code.google.com\p\log4go>ls
LICENSE  README  config.go  examples  filelog.go  log4go.go  log4go_test.go  pattlog.go  socklog.go  termlog.go  wrapper.go

E:\Dev_Root\go\src\code.google.com\p\log4go>ls -lha
total 94K
drwx------+ 1 Administrators None    0 Sep 20 17:05 .
drwx------+ 1 Administrators None    0 Sep 20 17:04 ..
drwx------+ 1 Administrators None    0 Sep 20 17:05 .hg
-rwx------+ 1 Administrators None  248 Sep 20 17:05 .hgtags
-rwx------+ 1 Administrators None 1.3K Sep 20 17:05 LICENSE
-rwx------+ 1 Administrators None  274 Sep 20 17:05 README
-rwx------+ 1 Administrators None 7.7K Sep 20 17:05 config.go
drwx------+ 1 Administrators None    0 Sep 20 17:05 examples
-rwx------+ 1 Administrators None 6.3K Sep 20 17:05 filelog.go
-rwx------+ 1 Administrators None  14K Sep 20 17:05 log4go.go
-rwx------+ 1 Administrators None  17K Sep 20 17:05 log4go_test.go
-rwx------+ 1 Administrators None 3.1K Sep 20 17:05 pattlog.go
-rwx------+ 1 Administrators None 1.1K Sep 20 17:05 socklog.go
-rwx------+ 1 Administrators None 1.2K Sep 20 17:05 termlog.go
-rwx------+ 1 Administrators None 8.3K Sep 20 17:05 wrapper.go

E:\Dev_Root\go\src\code.google.com\p\log4go>cd ../../bin
系统找不到指定的路径。

E:\Dev_Root\go\src\code.google.com\p\log4go>cd ..

E:\Dev_Root\go\src\code.google.com\p>cd ../

E:\Dev_Root\go\src\code.google.com>cd ..

E:\Dev_Root\go\src>cd ../bin

E:\Dev_Root\go\bin>ls

E:\Dev_Root\go\bin>cd ..

E:\Dev_Root\go>cd pkg

E:\Dev_Root\go\pkg>ls
windows_amd64

E:\Dev_Root\go\pkg>cd windows_amd64

E:\Dev_Root\go\pkg\windows_amd64>ls
code.google.com

E:\Dev_Root\go\pkg\windows_amd64>cd code.google.com

E:\Dev_Root\go\pkg\windows_amd64\code.google.com>ls
p

E:\Dev_Root\go\pkg\windows_amd64\code.google.com>cd p

E:\Dev_Root\go\pkg\windows_amd64\code.google.com\p>ls
log4go.a

E:\Dev_Root\go\pkg\windows_amd64\code.google.com\p>ls -lha
total 448K
drwx------+ 1 Administrators None    0 Sep 20 17:05 .
drwx------+ 1 Administrators None    0 Sep 20 17:05 ..
-rwx------+ 1 Administrators None 448K Sep 20 17:05 log4go.a

E:\Dev_Root\go\pkg\windows_amd64\code.google.com\p>

的确是在pkg下有log4go.a的

在src下,是有对应目录结构的:

installed log4go src and pkg

 

 

【总结】

此处通过go get安装包,出现:

exec: "hg": executable file not found in %PATH%

的错误,

原因是:

windows下没有安装Mercurial的hg(类似于cvs,svn,git的版本管理工具)

解决办法是:

去hg官网主页下载和安装即可:

【记录】windows下安装Mercurial的hg



One Thought on “【已解决】go语言用go get去安装第三方包出错:exec: "hg": executable file not found in %PATH%

  1. Pingback: o语言用go get去安装第三方包出错解决方法(摘录) | 王小峰的博客

发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量