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

后端 未结 5 709
醉话见心
醉话见心 2020-12-10 08:33

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 GOPA

相关标签:
5条回答
  • 2020-12-10 08:50

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

    0 讨论(0)
  • 2020-12-10 08:56

    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.

    0 讨论(0)
  • 2020-12-10 08:57

    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.

    0 讨论(0)
  • 2020-12-10 08:59

    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
    
    0 讨论(0)
  • 2020-12-10 08:59

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

    0 讨论(0)
提交回复
热议问题