Skip to content

Instantly share code, notes, and snippets.

@wolfgangmeyers
Last active May 11, 2017 15:27
Show Gist options
  • Save wolfgangmeyers/c7de046903d1fdfcf450440d62779450 to your computer and use it in GitHub Desktop.
Save wolfgangmeyers/c7de046903d1fdfcf450440d62779450 to your computer and use it in GitHub Desktop.
Sort interface boilerplate for golang in sublime text
<snippet>
<content><![CDATA[
// ${1:SortableList} implements sort.Interface for []${1:SortableType} based on
// the ${3:FieldName} field.
type ${1:SortableList} []${2:SortableType}
func (a ${1:SortableList}) Len() int { return len(a) }
func (a ${1:SortableList}) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ${1:SortableList}) Less(i, j int) bool { return a[i].${3:FieldName} < a[j].${3:FieldName} }
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>sort</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.go</scope>
<!-- Optional: Description to show in the menu -->
<description>Implement a sortable type</description>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment