I've searched golang-nuts and the Go issue tracker pretty extensively and I 
can't find any mention of my question or the topic, so would appreciate any 
links if this has been previously covered and I was simply using the wrong 
search terms.

go install takes a number of packages as arguments:

$ go install -help
usage: install [build flags] [packages]


Let's assume for the sake of discussion we're talking about:

go install github.com/fruit/banana


(where banana is a main package)

In writing documentation, particularly when it comes to code generators 
(but not exclusive to that), I find myself repeatedly asking the user to 
"ensure your path is correct..." so that when they now run:

banana -help


it invokes the banana binary we just installed.

This is relatively painful and error prone because of any permutation of 
problems/inconsistencies with PATH values, not to mention the potential for 
clashes in names of installed Go programs within $GOPATH/bin/

One way to deal with this is to do something like:

$(go list -f {{.Target}} github.com/fruit/banana) arg1 arg2 ...


but:

   1. I'm unsure how cross-platform this is
   2. it's not particularly pretty/friendly
   3. it doesn't work with go:generate directives
   4. it doesn't solve the problem of name clashes in $GOPATH/bin
   
What about therefore making go run (which currently only takes .go files as 
arguments to the go command) also understand the case of a single package 
argument:

go run github.com/fruit/banana arg1 arg2 ...


Arguments that are then passed on to the command as before (here arg1 arg2 
... are passed on to banana)

This would not build/install anything, it would simply exec the program 
most recently built via 'go install github.com/fruit/banana', or fail if 
not such file exists.

There are of course other details to work through... just looking to test 
the water with the thought.

Appreciate any links/feedback etc, particularly if actually others consider 
that I'm perceiving an issue where in fact there isn't one (i.e. I needn't 
even both writing about getting PATH correct in docs) and that name clashes 
are not common. 

But it would seem to be a nice way of further lowering the bar for new 
starters with the language, work cross-platform and not require any further 
environment tweaking.

Thanks,


Paul

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to