Open powerman opened 3 years ago
First one is obvious:
gobin -m -run github.com/golangci/golangci-lint/cmd/golangci-lint
is a way harder to type than justgolangci-lint
.
Agreed. The generally accepted solution for humans is to use aliases. For scripts/go:generate
directives, it doesn't really matter.
Second is a bit more subtle:
protoc
looks for installed plugins in PATH,
I think this is just a case of a PATH
based tool running up against a non-PATH
based tool. In this case I would probably drop down to using a script.
There are a couple usability issues related to absence of gobin-installed binaries in PATH. First one is obvious:
gobin -m -run github.com/golangci/golangci-lint/cmd/golangci-lint
is a way harder to type than justgolangci-lint
. Second is a bit more subtle:protoc
looks for installed plugins in PATH, so to let it find gobin-installed plugins we had to replace//go:generate protoc …
with something like//go:generate sh -c "protoc $(gobin -m -p $(go list -tags=tools -f '{{range .Imports}}{{println .}}{{end}}' ../../third_party | grep protoc-gen) | sed -e s,^,--plugin=,) …
(where../../third-party
is a directory containingtools.go
).Maybe it's worth to provide a way to run any command with PATH prepended with all directories with gobin-installed binaries in module-mode, e.g.:
Of course we can set PATH right now using command shown below, but there are a couple issues with it:
/bin/true
this way took3.531 real 12.202 user 3.191 sys 43MB RAM
Here is tools.go used in examples above: