google / go-github

Go library for accessing the GitHub v3 API
https://pkg.go.dev/github.com/google/go-github/v65/github
BSD 3-Clause "New" or "Revised" License
10.33k stars 2.05k forks source link

I have a question of dependency chain.. (go get error) #1549

Closed hahwul closed 4 years ago

hahwul commented 4 years ago

Hi, google team! It's not an issue, but I have a question. I'm using go-github in the module(go-github-selfupdate), which is causing the following error.

Chain my repo(github/dalfox) => go-github-selfdupdate(rhysd/go-github-selfupdate) => go-github/v30

Error message from go get

$ go get -u github.com/hahwul/dalfox
package github.com/google/go-github/v30/github: cannot find package "github.com/google/go-github/v30/github" in any of:
    /usr/local/go/src/github.com/google/go-github/v30/github (from $GOROOT)
    /home/hahwul/go/src/github.com/google/go-github/v30/github (from $GOPATH)

So I forked the repository and modify go.mod on forked repo, but I get another error..

I submit issue to module developer, but there was no answer. Is there any way I can handle it?

Cheers!

gmlewis commented 4 years ago

Edit: Actually, please try my last recommendation first, as that may fix the problem for you... see below.

Are all of these pieces using go.mod? Can you share the appropriate lines from go.mod and go.sum from each of the parts in the chain?

grep go-github go.*

Alternatively, can you try using the latest release of v32 ?

Also, can you explicitly type in go get -u github.com/google/go-github/v30/github on the command line and then try your other command again?

hahwul commented 4 years ago

Thank you so much for your reply! First of all, I want to upgrade to v32, but I think It seemed to be a problem caused by referencing v30 from go-github-selfupdate. So I thought it would be applied only if the module developer reflected it.

So, I was wondering if there was a way I could solve it myself. I share the go.mod of the associated module.

My tool's go.mod

module github.com/hahwul/dalfox

go 1.13

require (
    github.com/PuerkitoBio/goquery v1.5.1
    github.com/blang/semver v3.5.1+incompatible
    github.com/briandowns/spinner v1.10.0
    github.com/rhysd/go-github-selfupdate v1.2.2
    github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
    github.com/mitchellh/go-homedir v1.1.0
    github.com/spf13/cobra v1.0.0
)

go-github-selfupdate module's go.mod

module github.com/rhysd/go-github-selfupdate

require (
    github.com/blang/semver v3.5.1+incompatible
    github.com/google/go-github/v30 v30.1.0
    github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
    github.com/kr/pretty v0.1.0 // indirect
    github.com/onsi/gomega v1.4.2 // indirect
    github.com/tcnksm/go-gitconfig v0.1.2
    github.com/ulikunitz/xz v0.5.5
    golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288
    google.golang.org/appengine v1.3.0 // indirect
    gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)

go 1.13

Maybe it's because I don't know the go language very well. I'm trying to google it, but I haven't gotten a clever answer.

1414

gmlewis commented 4 years ago

OK, I just tried it all myself and it seems to work fine on my computer:

(base) glenn@glenn-XPS-8700 ~/src  $ cd github.com/
(base) glenn@glenn-XPS-8700 ~/src/github.com  $ mkdir hahwul
(base) glenn@glenn-XPS-8700 ~/src/github.com  $ cd !$
cd hahwul
(base) glenn@glenn-XPS-8700 ~/src/github.com/hahwul  $ git clone git@github.com:hahwul/dalfox
Cloning into 'dalfox'...
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 1211 (delta 39), reused 50 (delta 22), pack-reused 1130
Receiving objects: 100% (1211/1211), 203.22 KiB | 1.81 MiB/s, done.
Resolving deltas: 100% (726/726), done.
(base) glenn@glenn-XPS-8700 ~/src/github.com/hahwul  $ cd dalfox/
(base) glenn@glenn-XPS-8700 ~/src/github.com/hahwul/dalfox (master) $ cat go.mod
module github.com/hahwul/dalfox

go 1.13

require (
    github.com/PuerkitoBio/goquery v1.5.1
    github.com/blang/semver v3.5.1+incompatible
    github.com/briandowns/spinner v1.10.0
    github.com/rhysd/go-github-selfupdate v1.2.2
    github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
    github.com/mitchellh/go-homedir v1.1.0
    github.com/spf13/cobra v1.0.0
)
(base) glenn@glenn-XPS-8700 ~/src/github.com/hahwul/dalfox (master) $ go test ./...
go: finding github.com/PuerkitoBio/goquery v1.5.1
go: finding github.com/briandowns/spinner v1.10.0
go: finding github.com/mitchellh/go-homedir v1.1.0
go: finding github.com/blang/semver v3.5.1+incompatible
go: finding github.com/rhysd/go-github-selfupdate v1.2.2
go: finding github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
go: finding github.com/spf13/cobra v1.0.0
go: finding github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
go: finding github.com/kr/pretty v0.1.0
go: finding github.com/tcnksm/go-gitconfig v0.1.2
go: finding github.com/ulikunitz/xz v0.5.5
go: finding github.com/fatih/color v1.7.0
go: finding golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288
go: finding google.golang.org/appengine v1.3.0
go: finding golang.org/x/net v0.0.0-20200202094626-16171245cfb2
go: finding github.com/mattn/go-colorable v0.1.2
go: finding github.com/google/go-github/v30 v30.1.0
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding github.com/inconshreveable/mousetrap v1.0.0
go: finding github.com/cpuguy83/go-md2man/v2 v2.0.0
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding github.com/onsi/gomega v1.4.2
go: finding github.com/spf13/pflag v1.0.3
go: finding github.com/spf13/viper v1.4.0
go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
go: finding golang.org/x/text v0.3.0
go: finding github.com/google/go-querystring v1.0.0
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
go: finding github.com/andybalholm/cascadia v1.1.0
go: finding google.golang.org/appengine v1.1.0
go: finding github.com/russross/blackfriday/v2 v2.0.1
go: finding github.com/hashicorp/hcl v1.0.0
go: finding github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
go: finding go.uber.org/zap v1.10.0
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e
go: finding github.com/hpcloud/tail v1.0.0
go: finding github.com/coreos/bbolt v1.3.2
go: finding github.com/jonboulle/clockwork v0.1.0
go: finding github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef
go: finding go.uber.org/multierr v1.1.0
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/coreos/go-semver v0.2.0
go: finding go.uber.org/atomic v1.4.0
go: finding github.com/gogo/protobuf v1.2.1
go: finding github.com/fsnotify/fsnotify v1.4.7
go: finding github.com/golang/protobuf v1.2.0
go: finding gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: finding golang.org/x/net v0.0.0-20190522155817-f3200d17e092
go: finding github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
go: finding github.com/ugorji/go v1.1.4
go: finding github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
go: finding go.etcd.io/bbolt v1.3.2
go: finding github.com/pelletier/go-toml v1.2.0
go: finding golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01
go: finding github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5
go: finding github.com/spf13/afero v1.1.2
go: finding github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding google.golang.org/grpc v1.21.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/kisielk/errcheck v1.1.0
go: finding github.com/shurcooL/sanitized_anchor_name v1.0.0
go: finding github.com/coreos/etcd v3.3.10+incompatible
go: finding github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6
go: finding github.com/golang/protobuf v1.3.2
go: finding github.com/gorilla/websocket v1.4.0
go: finding github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
go: finding github.com/mitchellh/mapstructure v1.1.2
go: finding github.com/mattn/go-isatty v0.0.8
go: finding github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
go: finding github.com/BurntSushi/toml v0.3.1
go: finding golang.org/x/tools v0.0.0-20180221164845-07fd8470d635
go: finding honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
go: finding github.com/client9/misspell v0.3.4
go: finding github.com/golang/mock v1.1.1
go: finding golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
go: finding golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
go: finding github.com/soheilhy/cmux v0.1.4
go: finding github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77
go: finding github.com/google/btree v1.0.0
go: finding github.com/spf13/jwalterweatherman v1.0.0
go: finding github.com/kr/text v0.1.0
go: finding google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
go: finding github.com/google/go-cmp v0.2.0
go: finding github.com/onsi/ginkgo v1.6.0
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: finding golang.org/x/tools v0.0.0-20190311212946-11955173bddd
go: finding github.com/prometheus/client_golang v0.9.3
go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
go: finding github.com/kr/pty v1.1.1
go: finding cloud.google.com/go v0.26.0
go: finding github.com/magiconair/properties v1.8.0
go: finding github.com/grpc-ecosystem/grpc-gateway v1.9.0
go: finding golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
go: finding github.com/kisielk/gotool v1.0.0
go: finding golang.org/x/net v0.0.0-20180724234803-3673e40ba225
go: finding github.com/spf13/cast v1.3.0
go: finding github.com/go-logfmt/logfmt v0.4.0
go: finding github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
go: finding github.com/prometheus/common v0.4.0
go: finding gopkg.in/fsnotify.v1 v1.4.7
go: finding github.com/golang/protobuf v1.3.1
go: finding github.com/ghodss/yaml v1.0.0
go: finding golang.org/x/net v0.0.0-20181220203305-927f97764cc3
go: finding gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7
go: finding github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af
go: finding golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8
go: finding github.com/beorn7/perks v1.0.0
go: finding github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084
go: finding github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
go: finding gopkg.in/resty.v1 v1.12.0
go: finding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
go: finding github.com/go-kit/kit v0.8.0
go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: finding golang.org/x/net v0.0.0-20181114220301-adae6a3d119a
go: finding golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
go: finding github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
go: finding github.com/pkg/errors v0.8.0
go: finding github.com/matttproud/golang_protobuf_extensions v1.0.1
go: finding github.com/prometheus/client_golang v0.9.1
go: finding github.com/julienschmidt/httprouter v1.2.0
go: finding google.golang.org/grpc v1.19.0
go: finding github.com/sirupsen/logrus v1.2.0
go: finding github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
go: finding golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
go: finding github.com/go-logfmt/logfmt v0.3.0
go: finding golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5
go: finding github.com/go-stack/stack v1.8.0
go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go: finding github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
go: finding github.com/gogo/protobuf v1.1.1
go: finding github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d
go: finding golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3
go: finding golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
go: finding github.com/prometheus/tsdb v0.7.1
go: finding github.com/stretchr/objx v0.1.1
go: finding golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding golang.org/x/tools v0.0.0-20190114222345-bf090417da8b
go: finding golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
go: finding golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
go: finding github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce
go: finding github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954
go: finding github.com/cespare/xxhash v1.1.0
go: finding github.com/oklog/ulid v1.3.1
go: finding github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72
go: finding github.com/OneOfOne/xxhash v1.2.2
go: downloading github.com/spf13/cobra v1.0.0
go: downloading github.com/PuerkitoBio/goquery v1.5.1
go: downloading golang.org/x/net v0.0.0-20200202094626-16171245cfb2
go: downloading github.com/briandowns/spinner v1.10.0
go: downloading github.com/rhysd/go-github-selfupdate v1.2.2
go: downloading github.com/blang/semver v3.5.1+incompatible
go: downloading github.com/tcnksm/go-gitconfig v0.1.2
go: downloading github.com/ulikunitz/xz v0.5.5
go: downloading github.com/fatih/color v1.7.0
go: downloading github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
go: downloading github.com/mattn/go-colorable v0.1.2
go: downloading github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
go: downloading github.com/spf13/pflag v1.0.3
go: downloading github.com/andybalholm/cascadia v1.1.0
go: downloading github.com/google/go-github/v30 v30.1.0
go: downloading github.com/mattn/go-isatty v0.0.8
go: downloading golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288
go: downloading github.com/google/go-querystring v1.0.0
go: downloading golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: downloading golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
# github.com/hahwul/dalfox/pkg/printing
pkg/printing/logger.go:87:20: undefined: strings.ReplaceAll
pkg/printing/logger.go:90:20: undefined: strings.ReplaceAll
pkg/printing/logger.go:91:19: undefined: strings.ReplaceAll
note: module requires Go 1.13(base) glenn@glenn-XPS-8700 ~/src/github.com/hahwul/dalfox (master) $ 

Did you set any unusual environment variables? Here are mine:

$ env | grep -i go
GO111MODULE=auto
GOPATH=/home/glenn/go
hahwul commented 4 years ago

@gmlewis Thank you! Well, then I guess it's a problem with my development environment. I have one more question. Is there a big difference between go get in cloned repo and go get in other directories?

When I released the tool, I'm talk to user to go install after installing the binary or clone, but some users want to install it as go get. Sometimes people with the same problem as me report it. I'm wondering if there's a big difference.

Unless it's an easy part to talk, I'll just googling it! Anyway, I think it helped me solve the problem. Thank you very much!

gmlewis commented 4 years ago

Hmmm... if you choose the "git clone" path, then you can just cd into the cloned repo and type:

go install ./...

and that should be equivalent (as far as installation goes) to: go get -u repo/.... Note that the ... at the end finds everything in the repo that can be installed (all the "package main" programs).

I hope this answers your question... but if not, please feel free to clarify and I will try to answer better.

hahwul commented 4 years ago

@gmlewis Aha, I get it! Thank you! I think the best way is for me to inform the user meticulously!

Enjoy the rest of your day :D Cheers!