tomnomnom / hacks

A collection of hacks and one-off scripts
2.12k stars 633 forks source link

Go get deprecated. How to install properly? #47

Closed lkz0ne closed 2 years ago

lkz0ne commented 2 years ago

I am trying to use the html-tool I am getting the following when running go get url

~# go get github.com/tomnomnom/hacks/html-tool     
go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.
# github.com/tomnomnom/hacks/html-tool
go/pkg/mod/github.com/tomnomnom/hacks@v0.0.0-20210604135613-352c68ebc565/html-tool/main.go:22:14: undefined: css.Compile
go/pkg/mod/github.com/tomnomnom/hacks@v0.0.0-20210604135613-352c68ebc565/html-tool/main.go:27:12: cannot assign error to err in multiple assignment

So I did

~# go install github.com/tomnomnom/hacks/html-tool@latest                                                2 ⨯
go: finding module for package golang.org/x/net/html
go: finding module for package github.com/ericchiang/css
go: finding module for package github.com/tomnomnom/gahttp
go: found github.com/ericchiang/css in github.com/ericchiang/css v1.1.0
go: found github.com/tomnomnom/gahttp in github.com/tomnomnom/gahttp v0.0.0-20180905143706-793a49d82336
go: found golang.org/x/net/html in golang.org/x/net v0.0.0-20220111093109-d55c255bac03
# github.com/tomnomnom/hacks/html-tool
go/pkg/mod/github.com/tomnomnom/hacks@v0.0.0-20210604135613-352c68ebc565/html-tool/main.go:22:14: undefined: css.Compile
go/pkg/mod/github.com/tomnomnom/hacks@v0.0.0-20210604135613-352c68ebc565/html-tool/main.go:27:12: cannot assign error to err in multiple assignment

But I don't know how to execute the html-tool . Any hints?

Further, I tried

~# go build                                                                                              2 ⨯
# html-tool
./main.go:22:14: undefined: css.Compile
./main.go:27:12: cannot assign error to err in multiple assignment

What am I doing wrong?

lkz0ne commented 2 years ago

Please, some clue?

ilyaglow commented 2 years ago

Unfortunately, maintainer of github.com/ericchiang/css broke its public API and this repository doesn't have a go.mod file which could pin dependencies versions, so here we are. ~It seems you need to rename css.Compile to css.Parse on the line of code mentioned in the error, which is the easiest way~. Also, you can fix it by adding go.mod to avoid future issues:

git clone https://github.com/tomnomnom/hacks.git \
&& cd hacks \
&& go mod init hacks \
&& go mod tidy \
&& go get github.com/ericchiang/css@f08e94f04ef6 \
&& echo 'https://google.com' | go run html-tool/main.go tags title # it should output Google
lkz0ne commented 2 years ago

God bless you man. I saw myself looking for a alternative and i found it as an example ./xidel --silent --extract "//@src | //@href" https://google.com considering that the package is broken, it could be utile.

By the way, I get html-tool fixed by rename css.Compile to css.Parse in main.go as you prescribe. Thanks a lot.