brocaar / chirpstack-network-server

ChirpStack Network Server is an open-source LoRaWAN network-server.
https://www.chirpstack.io
MIT License
1.49k stars 546 forks source link

[GOLANG] Importing local packages but with the "github.com/brocaar/" prefix? #13

Closed gzwsc2007 closed 8 years ago

gzwsc2007 commented 8 years ago

I am new to Go, so please pardon me if this question is stupid.

When I pull down the loraserver repo, and do make, I get errors like internal/loraserver/interfaces.go:4:2: cannot find package "github.com/brocaar/loraserver/models" in any of: ........

internal/loraserver/loraserver.go:12:2: cannot find package "github.com/brocaar/loraserver/models" in any of:.........

If I change all the "github.com/brocaar/loraserver/....." to "loraserver/......", then the code compiles.

I am using GO 1.6 and my GOPATH and GOROOT are setup correctly. What I don't understand is that, why are we prepending loraserver with github.com/brocaar/? Isn't loraserver a local package instead of a vendor package?

Thanks in advance.

brocaar commented 8 years ago

This is because when you would do a go get github.com/brocaar/loraserver/..., Go would place all the source-code under $GOPATH/src/github.com/brocaar/loraserver/.... In Go it is common to use the full repo url as import path. In case of LoRa Server, all requirements are vendored, if that would not be the case a simple go get ./... would fetch all requirements for you 😄

When you move your clone to the above path ($GOPATH/src/github.com/brocaar/loraserver/...), everything should work.

gzwsc2007 commented 8 years ago

Thank you very much for answering my question! :D

mesameen commented 5 years ago

Is there anyway to change the import names from "github.com/xxx/xxx" to "common/xxx"(something as I want). My requirement is, I don't want to see these github.com/xxx/xxx in the build file to avoid the complete details about what I'm using if I open the go build file in text editor.

NguyenKyThinh94 commented 3 years ago

i think github and gitlab donate for go team a huge money :v