【问题】
折腾:
期间,用如下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | package main import ( "fmt" "log" "io/ioutil" "http" ) func main() { fmt.Printf( "this is EmulateLoginBaidu.go\n" ) fmt.Printf(baiduMainUrl) } |
去测试运行,结果出错:
D:\tmp\tmp_dev_root\go\src\github.com\user\EmulateLoginBaidu>go run EmulateLoginBaidu.go D:\tmp\dev_install_root\Go\src\pkg\http (from $GOROOT) D:\tmp\tmp_dev_root\go\src\http (from $GOPATH) |
如图:
即:
cannot find package "http" in any of |
【解决过程】
1.很明显,是没找到http这个库。
2.参考之前的:
貌似去需要去安装这个http包的:
http://golang.org/pkg/net/http/
3.接下来问题就是转化为:
4.解决了该问题后,接着就是已经解决了此问题了。
【总结】
摘录:
中的结论:
http是go语言的内置的库,所以无需安装,但是对应的引用方式是:
1 | import "net/http" |
而不是:
1 | import "http" |
此点需要注意。
转载请注明:在路上 » 【已解决】go语言运行出错:EmulateLoginBaidu.go:7:5: cannot find package "http" in any of