Skip to content

Instantly share code, notes, and snippets.

@sperelson
Created January 5, 2015 22:24
Show Gist options
  • Save sperelson/3b49f2ef625e2bbf18de to your computer and use it in GitHub Desktop.
Save sperelson/3b49f2ef625e2bbf18de to your computer and use it in GitHub Desktop.
BBEdit 11 scripts to help build GoLang files and apps
#!/bin/bash
# Builds a Go app where the src folder is part of the default folder structure
# This assumes you have the app's src folder open in BBEdit and not any of the subfolders. Otherwise horrible dirname dirname won't work
# Setting the GOPATH may be a mistake?
# You may desire finer control over the output
# The src's folder name may not be desirable as your binary name
folder=$(basename "$BBEDIT_INSTAPROJECT_ROOT")
if [ "$folder" != "" ]; then
cd $(dirname `dirname "$BBEDIT_INSTAPROJECT_ROOT"`)
GOPATH=$(dirname `dirname "$BBEDIT_INSTAPROJECT_ROOT"`) go build -o $folder $folder
fi
#!/bin/bash
# Builds a single .go file
# Setting the GOPATH may be a mistake?
fileext=${BB_DOC_NAME##*.}
if [ "$fileext" = "go" ]; then
cd $(dirname "$BB_DOC_PATH")
GOPATH=$(dirname "$BB_DOC_PATH") go build $BB_DOC_PATH
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment