whyrusleeping / gx

A package management tool
MIT License
1.88k stars 110 forks source link

Add an option to use package name and version in the import path for new developers #205

Open schomatis opened 6 years ago

schomatis commented 6 years ago

I would like to implement an experimental option that would change the package import paths from src/gx/ipfs/Qm-long-hash/pkg-name to src/gx/pkg/pkg-name/pkg-version that I think it would be very useful for new developers that want to start contributing. I don't want to change the default way gx works (I already tried to push that agenda in https://github.com/whyrusleeping/gx/issues/166 without much success :) just to have an option to set the gx/gx-go tandem in this human-readable mode for development environments.

From what I've seen in the code this seems reasonably possible to do without affecting much of the current code but I'm raising the issue to check what would be the potential pitfalls of this change.

The first that comes to mind is that go-ipfs has its import paths hardcoded to the gx/ipfs/hash format but I think that's the exception rather than the rule so this package could be added as an exception in the logic without obscuring the code (and both types of path can coexist in the $GOPATH/src/gx workspace without conflicts).

Another issue is that this scheme would not allow to import two packages with the same name and version but different hashes (in fact turning them into different pieces of data) but that seems like a reasonable constraint.

gx already seems to have a global configuration,

https://github.com/whyrusleeping/gx/blob/a904dc7b51445cbe7a6f3b1b46018c4c140a6148/gxutil/config.go#L15-L19

and gx-go could be extended in a similar manner.

schomatis commented 6 years ago

@Stebalien WDYT?

schomatis commented 6 years ago

@Stebalien

Stebalien commented 6 years ago

I don't see how this will help. Ideally, those paths only appear in build artifacts (once we stop leaving go-ipfs paths rewritten).

Also note, the efforts in https://github.com/whyrusleeping/gx/pull/206 should make this a moot point fairly soon. With those changes, a gx lock-install creates a vendor directory and then symlinks gx packages unrewritten into the vendor directory. Eventually, we'd like to replace our normal gx packages with these lock-based packages and make gx lock-install the default gx install command.

schomatis commented 6 years ago

Ok, I'll take a look at that patch then.