有什么聪明的方法可以在Go1之后取回exp / html?
I've installed the Go release version as root. Go1 removed all exp/ code.
Is there smart method to get exp/* back after Go1? (I mean how to install in my local GOPATH?)
[My Solution]
# pull from go repository to $HOME/repo/go
cd $HOME/repo
hg clone https://go.googlecode.com/hg/go
# make symbolic link to your GOPATH(eg. $HOME/go)
cd $HOME/go/src
ln -s $HOME/repo/go/src/pkg/exp .
我已经以root用户身份安装了Go发行版。 Go1删除了所有exp /代码。 p> \ n
在Go1之后有一种聪明的方法来获取exp / *吗? (我的意思是如何在本地GOPATH中安装?) p>
[我的解决方案] p>
#从go存储库中拉至$ HOME / repo / go
cd $ HOME / repo
hg克隆https://go.googlecode.com/hg/go
# make 指向您的GOPATH的符号链接(例如$ HOME / go)
cd $ HOME / go / src
ln -s $ HOME / repo / go / src / pkg / exp。
code> pre>
DIV>
Note: with go 1.4 (Q4, 2014), the url for that exp
package will change (again):
code.google.com/p/go.exp => golang.org/x/exp
That means now:
go get golang.org/x/exp
See "Go 1.4 subrepo renaming".
Regarding the html
package, it is in net/html
, so this will become (as commented by andybalholm):
go get golang.org/x/net/html
The exp/html library was incomplete which is why it was removed for Go1.
However if you really want to use it then
go get code.google.com/p/go/src/pkg/exp/html
may install it back for you. If you want a slightly more complete html parser then you might checkout http://code.google.com/p/go-html-transform/ as well it has an html5 parser as well as a css selector based scraping and transformation library.
EDIT: Apparently trying to go get the package that way doesn't really work. It appears the only way to install this is to checkout the go source code and then install from source. This is actually a really quick an painless process if you want to go that route.
Building from source is the way to do this. When you do the hg update
step though, note that since the exp tree is not tagged go1, that hg update release
won't get it for you. Instead hg update weekly
will get it, and is probably what you want.
Edit: Weekly releases were discontinued after Go 1, so hg update weekly
will access increasingly stale code. A better strategy is hg update tip
, then copy the exp directory or directories of interest somewhere and recompile it with whatever Go version you are using, Go 1.0.1, for example.
This answer is outdated.
This is covered in the golang wiki:
https://code.google.com/p/go-wiki/wiki/InstallingExp
% cd $GOPATH/src
% hg clone https://code.google.com/p/go go-exp
requesting all changes
adding changesets
adding manifests
adding file changes
added 13323 changesets with 50185 changes to 7251 files (+5 heads)
updating to branch default
3464 files updated, 0 files merged, 0 files removed, 0 files unresolved
% mv go-exp/src/pkg/exp .
% rm -rf go-exp
% go install exp/...
Then, to use it:
import "exp/proxy"
I tried this a few months ago and it worked pretty well. Also, when I ran go install ...
I limited it to only the package I was interested in: go install exp/html
(if I recall, correctly).
The exp packages have been moved to different repositories now, to make them easier to install. Now you can install the former exp/html with go get "golang.org/x/net/html".