Skip to content

Instantly share code, notes, and snippets.

@wolfgangmeyers
Last active May 11, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfgangmeyers/b169a86357493329035128856b842e66 to your computer and use it in GitHub Desktop.
Save wolfgangmeyers/b169a86357493329035128856b842e66 to your computer and use it in GitHub Desktop.
Implement a sortable type in go - visual studio code snippet
{
"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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment