Skip to content

Instantly share code, notes, and snippets.

@NirantK
Forked from austingebauer/gopath
Last active September 9, 2019 08:01
Show Gist options
  • Save NirantK/7f83f57e83552c3dba45e40cbf944c9f to your computer and use it in GitHub Desktop.
Save NirantK/7f83f57e83552c3dba45e40cbf944c9f 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/go/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