Re: [go-nuts] Must you "go get" remote imports manually?

3,915 views
Skip to first unread message

Jonathan Langevin

unread,
Oct 24, 2012, 1:52:33 PM10/24/12
to mmo...@google.com, golan...@googlegroups.com
Agreed, it seemed to me that remote imports would occur automatically, or at least by toggling a cli parameter in `go build/run`, but I haven't seen that ability...

On Wed, Oct 24, 2012 at 1:20 PM, <mmo...@google.com> wrote:
Hi All,

Remote package imports are *awesome*, but I was hoping that there would be a "go build/run" flag to automatically "go get" all missing remote packages.
Otherwise, it seems I need some sort of initialization tool (Makefile) or at least documented install steps in a README.

I haven't been able to find such an option -- is it supported?

Thanks!
-Michal

--
 
 

Michal Mocny

unread,
Oct 24, 2012, 1:55:13 PM10/24/12
to Jonathan Langevin, golan...@googlegroups.com
Yeah, I didn't want to mention it initially, but the documentation for
"go install" and others seems to imply that "go get" would happen
automatically..

-Michal

Steve McCoy

unread,
Oct 24, 2012, 1:56:07 PM10/24/12
to golan...@googlegroups.com, mmo...@google.com
If it's gettable, run "go get" inside your project dir.

minux

unread,
Oct 24, 2012, 1:57:15 PM10/24/12
to mmo...@google.com, golan...@googlegroups.com

On Thursday, October 25, 2012, wrote:
Remote package imports are *awesome*, but I was hoping that there would be a "go build/run" flag to automatically "go get" all missing remote packages.
Otherwise, it seems I need some sort of initialization tool (Makefile) or at least documented install steps in a README.
for go build, did you try "go get ."? i think it will do the trick.
i'm not sure how to conveniently go get dependencies for
go run files, but i think go run is only for quick throw-away
one file runs.

Jonathan Langevin

unread,
Oct 24, 2012, 1:59:20 PM10/24/12
to Michal Mocny, golan...@googlegroups.com
Ha, I got that impression as well.

This paragraph suggests that it would occur automatically, but then the followup example shows `go get someurl...` explicitly.

An import path can describe how to obtain the package source code using a revision control system such as Git or Mercurial. The go command uses this property to automatically fetch packages from remote repositories. For instance, the examples described in this document are also kept in a Mercurial repository hosted at Google Code, code.google.com/p/go.example. If you include the repository URL in the package's import path, go get will fetch, build, and install it automatically:

Jonathan Langevin

unread,
Oct 24, 2012, 1:59:42 PM10/24/12
to Michal Mocny, golan...@googlegroups.com
From this page, that is: http://golang.org/doc/code.html

DisposaBoy

unread,
Oct 24, 2012, 2:00:37 PM10/24/12
to golan...@googlegroups.com
use go get to install your package and its dependencies will be installed as well. go install and go install doesn't do any remote fetching which is the main difference between them and go get. go run doesn't apply here

Michal Mocny

unread,
Oct 24, 2012, 2:11:31 PM10/24/12
to Jonathan Langevin, golan...@googlegroups.com
Interesting, I can, in fact, run "go get" with specifying which
packages to get, and it will automatically pick them up based on
remote import statements.

So it should be sufficient to document "go get && go run main.go", or
something along those lines, and not need to worry about changing
remote packages over time.

Thats probably good enough, though I still think a "go build" flag
would be nice -- and that way it can be used with "go run" as well via
its build flags.

Michal Mocny

unread,
Oct 24, 2012, 2:11:53 PM10/24/12
to Jonathan Langevin, golan...@googlegroups.com
*without specifying, that is!

John Asmuth

unread,
Oct 24, 2012, 2:17:19 PM10/24/12
to golan...@googlegroups.com, mmo...@google.com
The following command line will fetch all missing remote packages (as well as build them) for any package in GOROOT or GOPATH.

$ go get ...

Jonathan Langevin

unread,
Oct 24, 2012, 2:47:25 PM10/24/12
to John Asmuth, golan...@googlegroups.com, mmo...@google.com
Nice... Many thanks for that

--
 
 

Johann Höchtl

unread,
Oct 24, 2012, 3:41:08 PM10/24/12
to golan...@googlegroups.com, mmo...@google.com


Am Mittwoch, 24. Oktober 2012 20:17:19 UTC+2 schrieb John Asmuth:
The following command line will fetch all missing remote packages (as well as build them) for any package in GOROOT or GOPATH.

$ go get ...

Which should be the same as

$ go get all

I am not entirely sure but according to
http://godoc.golang.org/cmd/go/#Description_of_package_lists
it seems so.
Reply all
Reply to author
Forward
0 new messages