Add this snippet to visual studio code as described at https://code.visualstudio.com/docs/editor/userdefinedsnippets
Also see https://gist.github.com/wolfgangmeyers/c7de046903d1fdfcf450440d62779450 for the sublime text version.
Add this snippet to visual studio code as described at https://code.visualstudio.com/docs/editor/userdefinedsnippets
Also see https://gist.github.com/wolfgangmeyers/c7de046903d1fdfcf450440d62779450 for the sublime text version.
{ | |
"Implement a sortable type in go": { | |
"prefix": "sortable", | |
"body": [ | |
"// ${1:SortableList} implements sort.Interface for []${2: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} }" | |
], | |
"description": "Implement a sortable type in go" | |
} | |