Skip to content

Instantly share code, notes, and snippets.

View gostyle.md

Go Styleguide

If you're visiting from the internet, feel free to learn from my style. This is a guide I use for my own Go apps both at Heroku and personally. I encourage you to setup one that works for your own team.

Much of this was taken from https://github.com/styleguide/ruby, which was in turn based on https://github.com/bbatsov/ruby-style-guide. Please add to this guide if you find any particular patterns or styles that I've adopted. Send me a message to ask for feedback.

Coding Style & Syntax

Use go fmt and CamelCase.

@technoweenie
technoweenie / gist:2155760
Created Mar 22, 2012
track meta data with resque jobs, like when it was queued.
View gist:2155760
module Resque
def push_with_meta(queue, item)
if item.respond_to?(:[]=)
item[:meta] = {:queued_at => Time.now.to_f}
end
push_without_meta(queue, item)
end
class Job
# Returns a Hash of the meta data related to this Job.
@marcel
marcel / gist:2100703
Created Mar 19, 2012
giftube – Generates an animated gif from a YouTube url.
View gist:2100703
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@potatosalad
potatosalad / project-web-reload.conf
Created Feb 11, 2012
Upstart + Bluepill + Unicorn with hot restart
View project-web-reload.conf
# /etc/init/project-web-reload.conf
pre-start script
initctl restart project-web
sleep 15
end script
exec /usr/local/rvm/bin/default_bluepill restart
@javan
javan / emoji.m
Created Jan 10, 2012
Campfire Emoji
View emoji.m
sDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
// People
@":smile:", @"\ue415",
@":blush:", @"\ue056",
@":smiley:", @"\ue057",
@":relaxed:", @"\ue414",
@":smirk:", @"\ue402",
@":heart_eyes:", @"\ue106",
@":kissing_heart:", @"\ue418",
@lenary
lenary / gitconfig.ini
Created Feb 18, 2011
a special excerpt of my gitconfig
View gitconfig.ini
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
@mojombo
mojombo / vwilight.vim
Created Jan 26, 2011
vwilight.vim: A TRUE Twilight color theme for Vim
View vwilight.vim
" Vim color file
" Converted from Textmate theme Twilight using Coloration v0.2.5 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
@adelcambre
adelcambre / README.txt
Created Jan 20, 2011
make messages containing *green* green and containing *red* red in Propane
View README.txt
curl https://gist.github.com/raw/788740/4b337df4be4be4338e2466ef775cd685b57d9601/gistfile1.diff | patch -p0
View standup.rb
#!/usr/bin/env ruby
require 'highline/system_extensions'
include HighLine::SystemExtensions
module Standup
module Control
extend self
def play
View lol
#!/usr/bin/env ruby
require 'open-uri'
category = ARGV[0] || 'fail'
url = "http://api.cheezburger.com/xml/category/#{category}/lol/random"
open(url) do |f|
xml = f.read
if xml =~ /LolImageUrl\>([^\<]*)/m
You can’t perform that action at this time.