Skip to content

Instantly share code, notes, and snippets.

@austingebauer
Last active September 9, 2019 08:01
Show Gist options
  • Save austingebauer/5797da51432061b5f5478d4b2d031137 to your computer and use it in GitHub Desktop.
Save austingebauer/5797da51432061b5f5478d4b2d031137 to your computer and use it in GitHub Desktop.
Set GOPATH, GOBIN, and PATH in current directory
#!/usr/bin/env bash
#
# Sets the GOPATH and GOBIN to the current directory.
# Adds GOBIN to the PATH.
#
# Usage:
# 1. Put this script somewhere on your PATH.
# 2. Enter directory of a golang project (contains src, pkg, bin)
# 3. Execute: . gopath
#
export GOPATH="`pwd`"
echo "GOPATH set to: ${GOPATH}"
export GOBIN="$GOPATH/bin"
echo "GOBIN set to: ${GOBIN}"
export PATH="${PATH}:${GOBIN}"
echo "Added GOBIN to PATH for the current session"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment