-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: cmd/go: provide a portable and simple way to run SDK-like Go tools #33518
Comments
In #33468 (comment), @bcmills brings up an interesting point:
I agree that within a module the result should be reproducible which is the reason However, that means that within a module, So |
It is possible to get the path to the installed binary in a portable way, with something like:
Note that this will still resolve the version and do extra work outside a module, so it's not instantaneous. |
Thank you. My current thinking is that the speed of |
It seems like your use cases for running this tool would always be within a module, though -- it's only relevant when developing programs using your giou.org/ui module. And for that, go run (or |
ISTM that #31173 would solve this reasonably, particularly if combined with an idea from @ianthehat of being able to pass a |
A random list of points to add to the conversation, followed by a question on how we should move forward:
Next stepsThis issue has been rumbling in the background for some time now and it seems, to my mind, worthy of tackling given the plethora of problems/issues/common stumbling blocks it would help to avoid (arguments along similar lines to why @rsc, @bcmills, @ianthehat - what do you see as the next steps? Any thoughts on how best to proceed from here? |
Closing this proposal in favour of #42088 ( |
The Gio library contains a module (gioui.org/ui) for creating GUI programs in Go. For desktop platforms, running a Gio program is as easy as any other Go program, provided you have a few common system libraries and a C compiler installed:
Running Gio programs on Android, iOS and in the browser requires packaging several support files and meta data, so the Gio project includes the
gogio
tool in the `gioui.org/cmd module to automate the tedious work.Note that the
gogio
tool is not general purpose: it is intrinsically bound to the gioui.org/ui module. Similar examples are thegobind
andgomobile
tools from the Gomobile project.This issue is about providing an easy and portable way to run such support tools.
In #33468 I described a possible solution in terms of
go run
becausego run
is very close to what I want. This is the simple and portable one-liner for creating an Android app for a Gio program:Unfortunately, according to #33468 (comment), #25416 and #25416 (comment), it is almost accidental that
go run
can run the above one-liner.go install
@bcmills brings up the usual way to use Go tools:
go install
and setting up $PATH to run them:However, setting up PATH is not portable and not nearly as simple as
go run
, in particular for Windows users.Case in point:
go env
can now set environment variables for the Go tool because (#30411)go build
#25416 (comment) suggests
which doesn't depend on the environment, but still more awkward than just
go run
.(Some) Solutions
go run
be the way to conveniently run Go commands without fiddling with the environment. cmd/go: speed up 'go run' by caching binaries #33468 is about speeding upgo run
so that it is (nearly) as fast as running ago install
'ed binary.go run
is also the only way to get reproducible builds; see proposal: cmd/go: provide a portable and simple way to run SDK-like Go tools #33518 (comment).go install
'ed programs are guaranteed to be in PATH.go install
'ed binary that doesn't depend on the environment.The text was updated successfully, but these errors were encountered: