go

Posted on (not yet posted) to ruby and go  

Go is a simple framework to share and distribute command-line utils with yourself (on other machines), friends, coworkers and … whomever might find them useful.

Getting Started

First install the go gem with:

sudo gem sources -a http://gems.github.com
sudo gem install sbraford-go

Next “setup” go (build your ~/.go directory) with:

go setup

See the list of go commands:

go

(when not passed any options, it simply shows a list of available commands)

Ok – nothing special so far. Let’s say your friend has an html2haml script that you need to use. While one script here and there wouldn’t be such a big deal, after a while it’d be nice to have an easier way to manage these types of utilities.

Managing your Go Plugins via Git

You now have a “~/.go” directory which we are going to turn into a publicly shared Git repository. If any Go Plugins require sensitive information, these should be placed in ~/.goconfig or environment variables. (or you can simply make a private git repository)

After you’ve created a new Git repository, leave the instructional page open. We’ll simply use an existing directory and add it to the remote repo, for example like this one .

Let’s get started:

cd ~/.go
git add .
git commit -m ‘first commit’
git remote add origin <your repo’s git url>
git push origin master

Now let’s add that recursive html2haml script. Go needs a raw file, so on this page we select the raw output and pass this link to go install:


go install http://github.com/sbraford/go-plugins/tree/master%2Fhtml2haml_recursive.rb?raw=true

You should see:
Installing plugin: Html2hamlRecursive
Html2hamlRecursive Plugin installed to: /Users/foo/.go/html2haml_recursive.rb

Now just add this to git and commit/push:

git add .
git commit -a -m “added recursive html2haml go plugin”
git push

Sharing Across Machines

Once you have your Go plugins directory stored at git, it’s trivial to clone this to other machines.

Simply cone your go plugin repository to ~/.go and you’re set.