Last active
February 1, 2021 20:59
-
-
Save foresthoffman/4e21c976b52653992ee2f61548a1530d to your computer and use it in GitHub Desktop.
goi - go install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# 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