Ross Light avatar Ross Light committed 3e4d763

Improve Go snippets

Comments (0)

Files changed (1)

UltiSnips/go.snippets

 # go UltiSnips
 
-snippet pa "package declaration" b
+snippet /^pa/ "package declaration" r
+// Package $1 provides ...
 package ${1:`!v strlen(expand("%:h:t")) ? expand("%:h:t") : ""`}
 
 $0
 endsnippet
 
-snippet im "import" b
+snippet /^im/ "import" r
 import (
 	$1
 )
 	$0
 endsnippet
 
-snippet f "function" b
+snippet /^f/ "function" r
 // $1 ${4:...}
 func ${1:Function}($2) ${3:error}${3/(.+)/(?1: )/}{
 	${0:// code...}
 }
 endsnippet
 
-snippet m "method" b
+snippet /^m/ "method" r
 // $3 ${6:...}
 func (${1:self} ${2:Type}) ${3:Function}($4) ${5:error}${5/(.+)/(?1: )/}{
 	${0:// code...}
 }
 endsnippet
 
-snippet st "struct" b
+snippet /^st/ "struct" r
 // ${2:A $1 ${3:is a...}}
 type ${1} struct {
 	$0
 }
 endsnippet
 
-snippet in "interface" b
+snippet /^in/ "interface" r
 // $1 ${2:is...}
 type ${1} interface {
 	$0
 defer $1.RUnlock()
 endsnippet
 
-# common names
-
 # common functions
-snippet test "gotest unit test"
+snippet /^test/ "gotest unit test" r
 func Test${1:Func}(t *testing.T) {
 	${0:// code...}
 }
 endsnippet
 
-snippet bench "gotest benchmark"
+snippet /^bench/ "gotest benchmark" r
 func Benchmark${1:Func}(b *testing.B) {
 	${0:// code...}
 }
 endsnippet
 
-snippet main "main()" b
+snippet /^main/ "main()" r
 func main() {
 	${0:// code...}
 }
 endsnippet
 
-snippet hf "http HandlerFunc" b
+snippet /^mstr/ "String() method" r
+func (${1:self} ${2:Type}) String() string {
+	${0:// code...}
+}
+endsnippet
+
+snippet /^merr/ "Error() method" r
+func (${1:self} ${2:Type}) Error() string {
+	${0:// code...}
+}
+endsnippet
+
+snippet /^hf/ "http HandlerFunc" r
 func ${1:Handler}(w http.ResponseWriter, req *http.Request) {
 	${0:// code...}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.