Go need absolute paths for importing files /github.com/urs/prjct
This is fine and good for utility libraries (JWT, encryption, image compression). Until you want to make a "starter" style project.
These proejcts are typically forked and directly worked on while changing their proejct names and github user.
This will break the absoule import paths and they would need to manaully change all paths that refer to the project its self.
What solutions do you guys see to this problem?
评论:
0xjnml:
LVCXD:Go need absolute paths for importing files
/github.com/urs/prjct
No,
go build
does not need absolute paths. Import paths are interpreted relative to$GOPATH/src
.
TheMerovius:https://golang.org/cmd/go/#hdr-Relative_import_paths
So seems like golang can use relative paths
It shouldn't, though.
The solution is that what you are doing is either a) a fork in the gh-sense, the same project, just created to experiment or create a PR. In that case, add your fork as a new remote to the repo and don't touch the import paths. Or b) a fork in the open source software sense, a new project, with changes, meant for actual usage and long-term maintained. In that case, changing the import paths is the correct thing to do.
