Add this as a snippet as described in http://docs.sublimetext.info/en/latest/extensibility/snippets.html
Also see https://gist.github.com/wolfgangmeyers/b169a86357493329035128856b842e66 for the same snippet in visual studio code.
Add this as a snippet as described in http://docs.sublimetext.info/en/latest/extensibility/snippets.html
Also see https://gist.github.com/wolfgangmeyers/b169a86357493329035128856b842e66 for the same snippet in visual studio code.
| <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> |