Last active
August 29, 2015 14:16
-
-
Save jpillora/46e378826f8f2e4d68a6 to your computer and use it in GitHub Desktop.
Sublime Auto-Complete Snippet - Go Class (Golang)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<name>Class</name> | |
<tabTrigger>class</tabTrigger> | |
<content><![CDATA[//${1:ClassName} is ${3:...} | |
type ${1:ClassName} struct { | |
${2} | |
} | |
//New${1:ClassName} creates a new ${1:ClassName} | |
func New${1:ClassName}(${2/\t?(\w+) ([\.\w\*]+)(\n)?/\l$1 $2,/mg}) *${1:ClassName} { | |
return &${1:ClassName}{ | |
${2/(\w+) ([\.\w\*]+)/\t$1\: \l$1,/g} | |
} | |
}]]></content> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To install – Preferences > Browse Packages... > Go > Create a new class.sublime-snippet file
To use Type
class
TAB
. Input the class name.TAB
Input newline separated class fields.TAB
Input a class comment. Will produce code like:Note, since we can only have regex-ish features to make use of, we're left with a trailing comma in the arguments list. This is automatically cleared if you use
goimports
.