[ANN] godep - easier reproducible builds

896 views
Skip to first unread message

Keith Rarick

unread,
Sep 11, 2013, 8:44:27 PM9/11/13
to golang-nuts
I'm happy to present a new tool for freezing package dependencies:

https://github.com/kr/godep

Documentation, including a brief "typical usage" guide and some
reference materials, are available at the above link.

Godep doesn't try to solve the "dependency hell" problem of
conflicting requirements. Its principle of operation: once you've got
your project building and running to your satisfaction, you can fix
the current set of dependencies and continue using exactly that set
until you consciously decide to update something.

This is an early release, and still has some rough edges, but we're
already using it successfully on a few projects in production at
Heroku. We'd welcome any feedback from you early adopters, especially
about things that seem broken.

skyb...@google.com

unread,
Sep 11, 2013, 9:15:38 PM9/11/13
to golan...@googlegroups.com
Seems like a nice idea for applications, similar to Dart's pubspec.lock files.

- Brian

Frank Schröder

unread,
Sep 24, 2013, 2:07:24 AM9/24/13
to golan...@googlegroups.com
Hi Keith,

I'm trying to use your godep tool but I'm stuck with an error message which I don't get. I'm not sure if its because my project setup is not right or because of a bug. go install works just fine.

My GOPATH looks like this:

    GOPATH=~/gopath:~/git/frank/cas-reference-service

When I run godep I get the following error:

    [cas-reference-service master] $ godep save
    godep: no Go source files in /Users/frschroeder/git/frank/cas-reference-service
    godep: error loading packages

For the project I've got the recommended layout:

    [cas-reference-service master] $ tree
    .
    ├── README.md
    ├── bin
    │   └── cas-reference-service
    ├── pkg
    └── src
        ├── cas-reference-service
        │   ├── main.go
        │   └── metrics.go
        └── server
           ├── handler.go
            └── server.go

Why doesn't godep find any go files? Doesn't it look recursively under src?

godep save cas-reference-service also doesn't work and neither does "godep save" inside the src/cas-reference-service dir.

Any idea what I'm doing wrong here?

Thx
Frank

Frank Schröder

unread,
Sep 24, 2013, 2:10:38 AM9/24/13
to golan...@googlegroups.com
As a side note I think using JSON for the dep file is not such a good idea. For one it is quite verbose for the information you want to store but you could consider that a matter of taste. If you'd use a flat file with <repo>\t<tag> then more tools could use the information, e.g. you could easily parse it from a shell script. Right now you'd need other tools or fire up a python interpreter.

Keith Rarick

unread,
Sep 24, 2013, 2:24:02 AM9/24/13
to Frank Schröder, golang-nuts
The usual layout is to put your project's repo inside the src directory
in your GOPATH. In your case, that would mean something like
/Users/frschroeder/gopath/src/cas-reference-service.
Inside that directory, you'd have .git and some .go source files, and
maybe a subdirectory or two if you have more than one package in the
repo. You'll set GOPATH to some constant value in your ~/.profile
(in this case export GOPATH=~/gopath), and never think about it
or change it again. So far, this is not specific to godep, just general
Go code layout.

The godep save command operates on packages, similar to most
of the go tool commands. If you give no arguments, it uses ".", and
otherwise it takes one or more import paths to scan. This means
you'll usually run godep save from the same place you run go install,
and this is typically at the repo root.

Example project: https://github.com/kr/go-heroku-example
(There's actually very little in that repo that's specific to Heroku.)
> --
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Frank Schröder

unread,
Sep 24, 2013, 3:04:16 PM9/24/13
to golan...@googlegroups.com, Frank Schröder
Thanks Keith,

that got me one big step further. go list -json works now from within the cas-reference-service directory but I still get the same error from godep. I've traced it down to this call in vcs.go which gets called with "mp/cas-reference-service" when being called from within the mp/cas-reference-service dir (which is the project repo dir):

func VCSForImportPath(importPath string) (*VCS, *vcs.RepoRoot, error) {
    log.Printf("VCSForImportPath %s", importPath)
    rr, err := vcs.RepoRootForImportPath(importPath, false)


[cas-reference-service master ↑] $ echo $GOPATH
/Users/frschroeder/src/go
frschroeder@Franks-MacBook-Pro:~/src/go/src$ cd mp/cas-reference-service/

[cas-reference-service master ↑] $ godep save
godep: unrecognized import path "mp/cas-reference-service"
godep: error loading packages
[cas-reference-service master ↑] $ go list
mp/cas-reference-service

Reply all
Reply to author
Forward
0 new messages