gothinkster / golang-gin-realworld-example-app

Exemplary real world application built with Golang + Gin
https://realworld.io
MIT License
2.52k stars 497 forks source link

Cannot find package ".../wangzitian0/..." #5

Closed adomokos closed 3 years ago

adomokos commented 6 years ago

I'd like to test drive this project locally. I followed the instructions listed on the README. Tried to run go test -v ./... -cover, but I received this error:

hello.go:9:2: cannot find package "github.com/wangzitian0/golang-gin-starter-kit/articles" in any of:
    /Users/xyz/Programming/Go/projects/src/github.com/gothinkster/golang-gin-realworld-example-app/vendor/github.com/wangzitian0/golang-gin-starter-kit/articles (vendor tree)
    /usr/local/opt/go/libexec/src/github.com/wangzitian0/golang-gin-starter-kit/articles (from $GOROOT)
    /Users/xyz/Programming/Go/projects/src/github.com/wangzitian0/golang-gin-starter-kit/articles (from $GOPATH)
hello.go:10:2: cannot find package "github.com/wangzitian0/golang-gin-starter-kit/common" in any of:
    /Users/xyz/Programming/Go/projects/src/github.com/gothinkster/golang-gin-realworld-example-app/vendor/github.com/wangzitian0/golang-gin-starter-kit/common (vendor tree)
    /usr/local/opt/go/libexec/src/github.com/wangzitian0/golang-gin-starter-kit/common (from $GOROOT)
    /Users/xyz/Programming/Go/projects/src/github.com/wangzitian0/golang-gin-starter-kit/common (from $GOPATH)
hello.go:11:2: cannot find package "github.com/wangzitian0/golang-gin-starter-kit/users" in any of:
    /Users/xyz/Programming/Go/projects/src/github.com/gothinkster/golang-gin-realworld-example-app/vendor/github.com/wangzitian0/golang-gin-starter-kit/users (vendor tree)
    /usr/local/opt/go/libexec/src/github.com/wangzitian0/golang-gin-starter-kit/users (from $GOROOT)
    /Users/xyz/Programming/Go/projects/src/github.com/wangzitian0/golang-gin-starter-kit/users (from $GOPATH)

Why is the hello.go file is referencing a different repo's model here? Was it a incorrect merge? Am I missing something?

adomokos commented 6 years ago

I also pulled wangzitian0's repo and that worked.

wangzitian commented 6 years ago

@adomokos The two repo are totally same, caused by I'm lazy to write relative path. Govendor should auto download the packages to src/ from github.

adomokos commented 6 years ago

I wonder what I did wrong with govendor, it never pulled in those dependencies.

Feel free to close this issue if you think it's not something you would be concerned about.

mike-jianxin-mo commented 6 years ago

I got the same problem and solved it by replacing all the "wangzitian0/golang-gin-starter-kit" to "golang-gin-realworld-example-app" in the application.

PS. I have created a symlink under the $GOPATH/src/github.com to point to the directory I cloned this repo.

golang-gin-realworld-example-app -> /<directories ... >/learning/golang-gin-realworld-example-app/
wangzitian0 commented 6 years ago

@mike-jianxin-mo The correct way might need to use relative path here. I did not know the project will fork to two place while I wrote this project, and used absolute path. Sorry for the mistake.

BrutalSimplicity commented 5 years ago

@wangzitian0 And how might one go about using a relative path? After a quick search, it appears that relative path imports aren't a thing in Go (https://stackoverflow.com/questions/38517593/relative-imports-in-go). All imports must start via the $GOROOT. Wouldn't it be better to rename the imports in this repository to the folder they would be cloned into by default "golang-gin-realworld-example-app"? That way this isn't an issue for people cloning the repository.

g33klord commented 5 years ago

this need to be merged asap.

This should be followed everytime contributing to a go project: https://splice.com/blog/contributing-open-source-git-repositories-go/