Skip to content

Instantly share code, notes, and snippets.

@foresthoffman
Last active February 1, 2021 20:59
Show Gist options
  • Save foresthoffman/4e21c976b52653992ee2f61548a1530d to your computer and use it in GitHub Desktop.
Save foresthoffman/4e21c976b52653992ee2f61548a1530d to your computer and use it in GitHub Desktop.
goi - go install
##
# goi - Go Install
#
# Executable designed to grab local `src/` files and generate a binary from them.
#
# For more Go-semantic libraries, the current directory name is used.
#
# Author: Forest Hoffman <github.com/foresthoffman>
# All rights reserved.
##
pwdBase=$(basename "$PWD")
if [ "$pwdBase" == "src" ]; then
parent=$(dirname "$PWD")
parentBase=$(basename "$parent")
target="$parentBase"
else
target="$pwdBase"
fi
go build -o "$target" && mv "./$target" "$GOPATH/bin/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment