在Go1之后,有没有任何聪明的方法来获取exp/html?

huangapple go评论68阅读模式
英文:

Any smart method to get exp/html back after Go1?

问题

我已经以root用户安装了Go的发布版本。
Go1移除了所有exp/代码。

在Go1之后,有没有聪明的方法来获取exp/*?
(我的意思是如何在我的本地GOPATH中安装?)

[我的解决方案]

# 从go存储库中拉取到$HOME/repo/go
cd $HOME/repo
hg clone https://go.googlecode.com/hg/go
# 在你的GOPATH(例如$HOME/go)中创建符号链接
cd $HOME/go/src
ln -s $HOME/repo/go/src/pkg/exp .
英文:

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 .

答案1

得分: 5

exp/html库不完整,所以在Go1中被移除了。

然而,如果你真的想使用它,可以使用以下命令重新安装:

go get code.google.com/p/go/src/pkg/exp/html

如果你想要一个稍微更完整的HTML解析器,你可以尝试一下http://code.google.com/p/go-html-transform/,它还有一个基于CSS选择器的抓取和转换库,同时也包含一个HTML5解析器。

编辑:显然,尝试使用上述方式安装包并不起作用。似乎唯一的安装方式是检出Go源代码,然后从源代码安装。如果你选择这种方式,实际上这是一个非常快速和简单的过程。

英文:

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.

答案2

得分: 2

从源代码构建 是这样做的方法。但是,在执行 hg update 步骤时,请注意,由于 exp 树没有标记为 go1,因此 hg update release 不会为您获取它。相反,hg update weekly 将获取它,并且可能是您想要的。

编辑:在 Go 1 之后,每周发布已停止,因此 hg update weekly 将访问越来越陈旧的代码。更好的策略是 hg update tip,然后将 exp 目录或感兴趣的目录复制到其他地方,并使用您正在使用的任何 Go 版本(例如 Go 1.0.1)重新编译它。

英文:

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.

答案3

得分: 1

注意:从go 1.4(2014年第四季度)开始,exp包的url将再次更改

code.google.com/p/go.exp => golang.org/x/exp

这意味着现在应该使用:

go get golang.org/x/exp

参见“Go 1.4子仓库重命名”。

关于html包,它现在在net/html中,所以应该使用以下命令(由andybalholm在评论中提到):

go get golang.org/x/net/html
英文:

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

答案4

得分: 0

这个答案已经过时了。

这在golang wiki中有详细介绍:

https://code.google.com/p/go-wiki/wiki/InstallingExp

% cd $GOPATH/src
% hg clone https://code.google.com/p/go go-exp
请求所有更改
添加变更集
添加清单
添加文件更改
添加了13323个变更集,对7251个文件进行了50185次更改(+5个头)
更新到默认分支
更新了3464个文件,合并了0个文件,删除了0个文件,解决了0个文件
% mv go-exp/src/pkg/exp .
% rm -rf go-exp
% go install exp/...

然后,使用它:

import "exp/proxy"

我几个月前尝试过这个方法,效果还不错。另外,当我运行go install ...时,我只限制了我感兴趣的包:go install exp/html(如果我记得正确的话)。

英文:

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).

答案5

得分: 0

现在,exp包已经被移动到不同的存储库中,以便更容易安装。现在,您可以使用go get "golang.org/x/net/html"来安装以前的exp/html包。

英文:

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".

huangapple
  • 本文由 发表于 2012年4月3日 10:27:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/9986329.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定