0

I am trying to start my first Go project based on someone else's code, so I download his GitHub repo as zip, upload it to my own repo. Then use go get -u github.com/@username/@repo to install my repo, and add a replace statement to go.mod:

replace someone/repo v4.19.1+incompatible => ./

As a result, when I try go test ./... and go build ./... in the top directory, I get an error saying use of internal package xxx/yyy/internal not allowed. I am sure the only file include import xxx/yyy/internal is at the dir xxx/yyy, which should match the restriction of internal package of Go.

I don't know why go test ./... runs well in the original repo, but fails in my repo. Is there anything else I need to do to modify other people's repo?

Any help is appreciated, thanks!

Jiahao Cai
  • 1,222
  • 1
  • 11
  • 25
  • 1
    Seeing how this is a v4 package, I'm guessing something is importing via the incorrect module path. – JimB Apr 06 '20 at 21:00
  • Where should I edit the module path? Sorry I am totally new to Go :/ – Jiahao Cai Apr 06 '20 at 21:03
  • if nothing is importing the /v4 path, then are you certain you're using module mode? What version of Go are you using? – JimB Apr 06 '20 at 21:07
  • I am not sure, and I am using go 1.14. – Jiahao Cai Apr 06 '20 at 21:12
  • 1
    I found that I changed the first line of `go.mod` to `module myusername@repo`, change it back solves the problem... Thanks for the keywords you provided, searching them gives me some solutions. @JimB – Jiahao Cai Apr 06 '20 at 21:54

0 Answers0