Skip to content

Instantly share code, notes, and snippets.

@tj
Last active November 13, 2015 18:32
Show Gist options
  • Save tj/93a31088ea0e47d25386 to your computer and use it in GitHub Desktop.
Save tj/93a31088ea0e47d25386 to your computer and use it in GitHub Desktop.
Atom snippets for Go
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# prefix: 'log'
# body: 'console.log $1'
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it here:
# https://github.com/bevry/cson#what-is-cson
'.source.go':
'Map':
'prefix': 'ma'
'body': 'map[string]interface{}'
'HTTP Handler':
'prefix': 'ha'
'body': 'w http.ResponseWriter, r *http.Request'
'Log Printf':
'prefix': 'l'
'body': 'log.Printf("$1", $2)'
'Return':
'prefix': 'r'
'body': 'return'
'Package':
'prefix': 'p'
'body': 'package $0'
'Tag':
'prefix': 'tag'
'body': '`$1:"$2"`'
'Bytes':
'prefix': 'b'
'body': '[]byte($1)'
'Import':
'prefix': 'i'
'body': '''
import (
"$1"
)
'''
'Function':
'prefix': 'f'
'body': '''
func $1($2) $3 {
$0
}
'''
'If Error':
'prefix': 'e'
'body': '''
if err != nil {
$0
}
'''
'Struct':
'prefix': 's'
'body': '''
type $1 struct {
$0
}
'''
'Method':
'prefix': 'm'
'body': '''
func ($1 *$2) $3($4) $5 {
$0
}
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment