Hacker News new | ask | show | jobs
by calcifer 2745 days ago
How will that work with modules though? As in, how do you vendor a single library (that you want to make a fix to) while still building with module support? Right now, "module mode" is mutually exclusive with "vendor mode" and I don't think there are any plans to change that.
1 comments

> Right now, "module mode" is mutually exclusive with "vendor mode" and I don't think there are any plans to change that.

This is not true. If you pass -mod=vendor, or place it in $GOFLAGS, go will build something outside of GOPATH, in module mode, using the vendor directory exclusively. I wish it was the default, but only because it encourages people to not use vendor directories (which is a bad habit), not because it can't be worked around easily.

> in module mode, using the vendor directory exclusively

But that's not what I'm asking. I want "go build" (with some flags) to use my fork (vendored if needed) for one library, and pick up all other dependencies from the module cache as usual. How do I that?

Because this is already possible in a vendor-only world; I just edit the code in vendor.

You check out the dependency you want to change and add a replace directive in go.mod. Either a temporary one to a file system path or a permanent one to a forked repository.
Why are vendor directories a bad habit ? There just shouldn't be any GOPATH at all as far as I'm concerned.

Look in /usr/include. There you can see what's wrong with GOPATH, 5 years in the future. Now try installing 2 different versions of libraries.

I'll wait.

> Why are vendor directories a bad habit ?

They aren't, not having them is.