Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Automatially manage Go(lang) project workspaces by looking for a .goproj file up in the tree and setting GOPATH to it's location.
Shell
#4
Branch: multi_commands…
#4 Compare This branch is 4 commits ahead of master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
libexec
README.md

README.md

GoProj

GoProj makes it easier to manage project-specific GOPATH entries. It looks for a .goproj file up in the directory tree and if it finds one, prepends the file location to the GOPATH environment variable.

Installation

  1. Clone the repository

    git clone git://github.com/divoxx/goproj
  2. Enter the project folder

    cd goproj
  3. Add the bin/ folder to your PATH

    echo "export PATH=\"$(pwd)/bin:${PATH}\"" >> ~/.bashrc
  4. Alias the go command to the goproj-go executable:

    echo "alias go=\"goproj-go\"" >> ~/.bashrc
  5. Optionaly reload your bashrc

    source ~/.bashrc

If you're on OS X, use ~/.bash_profile instead of ~/.bashrc.

Usage

Simply go into your project's folder and touch .goproj. Now goproj will recognize this folder as a go path and will automatically prepend it to $GOPATH when you run goproj (or goproj-go) from within that directory (or a subdirectory).

Your projects will need to follow the same directory structure of any GOPATH. For example, a new project would look like this:

$ ls -1Ap ~/projects/foo
.goproj
bin/
pkg/
src/

Any go command that you run from whithin that ~/projects/foo, or any subdirectory, ~/projects/foo will be prepended to $GOPATH, properly resolving any dependencies during the build process. Also, if you go get or go install something, it will be installed inside that folder.

Usage: goproj [options] [--] COMMAND

Options:
  -h    show this screen
  -x    set GOPATH strictly to your project path, not keeping the original
  -s    open a new shell with the environment setup to the project
  -v    show the version

Description:

  Search for a .goproj file up in the directory tree. If one is found, prepend
  it's directory to the GOPATH env variable and execute COMMAND.

  If no .goproj file is found, it stops when it reaches the root folder, and
  executes COMMAND

Examples:

  goproj godoc -http=:6060
  goproj -s

Go tool wrapper:

  goproj comes with the goproj-go executable, which wraps the go tool, setting up
  the environment prior to actually executing the toolchain command.

  To take full advantage of it, it's recommended to alias the "go" command to it:

    alias go="goproj-go"

  After setting the alias, one can simply do:

    go build -a -n

  And it will in fact execute:

    goproj -- go build -a -n

License

Copyright (c) 2013 Rodrigo Kochenburger

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.