Skip to content

Instantly share code, notes, and snippets.

@kvick
kvick / go-shebang-story.md
Created December 4, 2018 17:39 — forked from posener/go-shebang-story.md
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

commit a9d615ab705fd7ae4e6a11722d22997235b33f9b
Author: Tim Gardner <[email protected]>
Date: Tue May 21 08:14:16 2013 -0600
UBUNTU: Rebase to 2d3c627502f2a9b0a7de06a5a2df2365542a72c9
Signed-off-by: Tim Gardner <[email protected]>
===
This commit introduced the file debian.master/config/config.common.ubuntu with the option:
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
@kvick
kvick / gist:5536855
Created May 7, 2013 22:55
Jenkins Build step (execute shell) for aminator/testing. Make sure to set the environment variables (PYTHONPATH=${WORKSPACE}) so that the aminator_versioning.py can find the version file The git publisher pushes $TAG to testing when the build succeeds
PYTHON_COMMAND="python2.7"
UPDATE_VERSION_COMMAND="${PYTHON_COMMAND} /usr/local/bin/aminator_versioning.py"
MAJOR_MINOR_VERSION=`${UPDATE_VERSION_COMMAND} -d`
POSTFIX="dev"
# RPM doesn't support '-'
TAG="$MAJOR_MINOR_VERSION.${BUILD_NUMBER}-$POSTFIX"
RPM_TAG="$MAJOR_MINOR_VERSION.$POSTFIX${BUILD_NUMBER}"
VERSION_FILE=aminator/__init__.py
INSTALL_DIR="/apps/aminator"
#!/usr/bin/env python2.7 #
# version helper for the aminator project
#
# This script is to be called from a Jenkins job
# 1. do a release build. take the current build and remove the -dev suffix, keep the rest of the version the same
# 2. do a testing build. take the current build number, add the -dev suffix, update version
#
import logging
import optparse
@kvick
kvick / gist:5446896
Created April 23, 2013 19:59
Jenkins script to build aminator+deps in virtualenv
MAJOR_VERSION=1
MINOR_VERSION=0
RELEASE_VERSION=${BUILD_NUMBER}
POSTFIX="dev"
# RPM doesn't support '-'
TAG="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION-$POSTFIX"
RPM_TAG="$MAJOR_VERSION.$MINOR_VERSION.$POSTFIX$RELEASE_VERSION"
VERSION_FILE=aminator/__init__.py
TO_BRANCH="integration"
INSTALL_DIR="/apps/aminator"
@kvick
kvick / gist:5092810
Created March 5, 2013 18:26
jenkins git plugin 1.20 trying to add a merge before build advanced config
Status Code: 500
Exception: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {"":["hudson.plugins.git.util.DefaultBuildChooser","auto"],"authorOrCommitter":false,"branches":{"name":"master"},"buildChooser":{"stapler-class":"hudson.plugins.git.util.DefaultBuildChooser"},"clean":false,"disableSubmodules":false,"excludedRegions":"","excludedUsers":"","gitConfigEmail":"","gitConfigName":"","gitTool":"Default","ignoreNotifyCommit":false,"includedRegions":"","localBranch":"","pruneBranches":false,"recursiveSubmodules":false,"reference":"","relativeTargetDir":"","remotePoll":false,"scmName":"","skipTag":false,"useShallowClone":false,"userMergeOptions":{"mergeRemote":"ssh://[email protected]:7999/ENGTOOLS/chef-solo-cookbooks.git","mergeTarget":"master"},"userRemoteConfigs":{"name":"","refspec":"","url":"ssh://[email protected]:7999/ENGTOOLS/chef-repo.git"},"value":"2","wipeOutWorkspace":false}
Stacktrace:
javax.servlet.ServletException: java.lang.RuntimeExcepti