5

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 .
Daniel YC Lin
  • 15,050
  • 18
  • 63
  • 96
  • Note: go 1.4 (Q4 2014) will change the url again: see [my answer below](http://stackoverflow.com/a/26773479/6309). – VonC Nov 06 '14 at 06:59

5 Answers5

5

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.

Jeremy Wall
  • 23,907
  • 5
  • 55
  • 73
  • 1
    `go get code.google.com/p/go/src/pkg/exp/html` got error messages as: package code.google.com/p/go/src/pkg/exp/html imports code.google.com/p/go/src/pkg/exp/html imports code.google.com/p/go/src/pkg/exp/html: import code.google.com/p/go/src/pkg/exp/html": **cannot find package** – Daniel YC Lin Apr 03 '12 at 07:09
  • 1
    Could you add some document on the main site of go-html-transform. Especial example code and how to 'go get your package'. – Daniel YC Lin Apr 03 '12 at 07:15
  • Ugh, I hadn't actually tried to get exp/html that way myself. That's too bad. I'll see about adding more documentation for html transform to it's project page. – Jeremy Wall Apr 03 '12 at 18:18
  • FYI: The author of exp/html is nearly ready to release a complete version so this may get a lot easier soon. – Jeremy Wall Aug 10 '12 at 04:00
2

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.

Sonia
  • 27,135
  • 8
  • 52
  • 54
1

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
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

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

tiffon
  • 5,040
  • 25
  • 34
0

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

andybalholm
  • 15,395
  • 3
  • 37
  • 41