an example I think is important, and should be considered important in the
design of Go.
Suppose i have a hypothetical project constant_time_sorting which has 3
packages, the main constant_time_sorting along with subpackages
magic_algorithm and utilities organized like so:
constant_time_sorting/
magic_algorithm/
utilities/
And, i host this project on github at
github.com/rliebling/constant_time_sorting
If i understand correctly, to import my subpackages (magic_algorithm and
utilities) i will not be able to use a local import (since my project is
hosted on github.com, obtained via go get
github.com/rliebling/constant_time_sorting, it is not a local project).
So, i have to specify the full import path for magic_algorithm and
utilities.
Now, if someone else were to fork my project (say to fix a bug), they will
have to change the import paths before being able to build their copy of
this project (since it is also a remote project). They fix the bug and
kindly submit a pull request to me to incorporate into what will quickly
become a popular Go project. However, someone has to play some games with
the pull request (either the submitter or the receiver) since the changes
they had to make included changing import paths.
This seems like a serious impediment to a common github workflow. And,
it's not really unique to github either. the point is that one cannot just
fork a project and have it build without first making changes. And, that
seems like a bad call. Admittedly, i don't understand what it would take
to implement a solution that allows local (relative) imports within a
remote project but it seems like a very important feature and I would
encourage the team to make it happen. I have not done much go programming,
but it's already negatively impacted me several times.
best
rich
On Sunday, March 11, 2012 12:53:47 PM UTC-7, rsc wrote:
*** Submitted as fc524d42fb8c ***
cmd/go: local import fixes
1) The -D argument should always be a pseudo-import path,
like _/Users/rsc/foo/bar, never a standard import path,
because we want local imports to always resolve to pseudo-paths.
2) Disallow local imports in non-local packages. Otherwise
everything works but you get two copies of a package
(the real one and the "local" one) in your binary.
R=golang-dev, bradfitz, yiyu.jgl
CC=golang-dev
http://codereview.appspot.com/5787055
http://codereview.appspot.com/5787055/
*** Submitted as fc524d42fb8c ***
cmd/go: local import fixes
1) The -D argument should always be a pseudo-import path,
like _/Users/rsc/foo/bar, never a standard import path,
because we want local imports to always resolve to pseudo-paths.
2) Disallow local imports in non-local packages. Otherwise
everything works but you get two copies of a package
(the real one and the "local" one) in your binary.
R=golang-dev, bradfitz, yiyu.jgl
CC=golang-dev
http://codereview.appspot.com/5787055
http://codereview.appspot.com/5787055/