2019-04-28 21:19:54 -06:00
|
|
|
package snippets
|
|
|
|
|
2019-11-22 12:49:12 -07:00
|
|
|
type AliasType = int //@item(sigAliasType, "AliasType", "AliasType", "type")
|
|
|
|
|
2019-07-02 16:10:05 -06:00
|
|
|
func foo(i int, b bool) {} //@item(snipFoo, "foo", "func(i int, b bool)", "func")
|
|
|
|
func bar(fn func()) func() {} //@item(snipBar, "bar", "func(fn func())", "func")
|
2019-11-22 12:49:12 -07:00
|
|
|
func baz(at AliasType, b bool) {} //@item(snipBaz, "baz", "func(at AliasType, b bool)", "func")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
|
|
|
type Foo struct {
|
|
|
|
Bar int //@item(snipFieldBar, "Bar", "int", "field")
|
2019-11-22 12:49:12 -07:00
|
|
|
Func func(at AliasType) error //@item(snipFieldFunc, "Func", "func(at AliasType) error", "field")
|
2019-04-28 21:19:54 -06:00
|
|
|
}
|
|
|
|
|
2019-07-02 16:10:05 -06:00
|
|
|
func (Foo) Baz() func() {} //@item(snipMethodBaz, "Baz", "func() func()", "method")
|
|
|
|
func (Foo) BazBar() func() {} //@item(snipMethodBazBar, "BazBar", "func() func()", "method")
|
2019-11-22 12:49:12 -07:00
|
|
|
func (Foo) BazBaz(at AliasType) func() {} //@item(snipMethodBazBaz, "BazBaz", "func(at AliasType) func()", "method")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
|
|
|
func _() {
|
2019-09-04 11:23:14 -06:00
|
|
|
f //@snippet(" //", snipFoo, "foo(${1:})", "foo(${1:i int}, ${2:b bool})")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
2019-09-04 11:23:14 -06:00
|
|
|
bar //@snippet(" //", snipBar, "bar(${1:})", "bar(${1:fn func()})")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
2019-11-22 12:49:12 -07:00
|
|
|
baz //@snippet(" //", snipBaz, "baz(${1:})", "baz(${1:at AliasType}, ${2:b bool})")
|
|
|
|
baz() //@signature("(", "baz(at AliasType, b bool)", 0)
|
|
|
|
|
2019-05-17 11:45:59 -06:00
|
|
|
bar(nil) //@snippet("(", snipBar, "bar", "bar")
|
2019-09-04 11:23:14 -06:00
|
|
|
bar(ba) //@snippet(")", snipBar, "bar(${1:})", "bar(${1:fn func()})")
|
2019-04-28 21:19:54 -06:00
|
|
|
var f Foo
|
2019-05-13 14:49:29 -06:00
|
|
|
bar(f.Ba) //@snippet(")", snipMethodBaz, "Baz()", "Baz()")
|
2019-09-04 11:23:14 -06:00
|
|
|
(bar)(nil) //@snippet(")", snipBar, "bar(${1:})", "bar(${1:fn func()})")
|
2019-05-13 21:09:27 -06:00
|
|
|
(f.Ba)() //@snippet(")", snipMethodBaz, "Baz()", "Baz()")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
|
|
|
Foo{
|
2019-09-04 11:23:14 -06:00
|
|
|
B //@snippet(" //", snipFieldBar, "Bar: ${1:},", "Bar: ${1:int},")
|
2019-04-28 21:19:54 -06:00
|
|
|
}
|
|
|
|
|
2019-11-22 12:49:12 -07:00
|
|
|
Foo{
|
|
|
|
F //@snippet(" //", snipFieldFunc, "Func: ${1:},", "Func: ${1:func(at AliasType) error},")
|
|
|
|
}
|
|
|
|
|
2019-09-04 11:23:14 -06:00
|
|
|
Foo{B} //@snippet("}", snipFieldBar, "Bar: ${1:}", "Bar: ${1:int}")
|
|
|
|
Foo{} //@snippet("}", snipFieldBar, "Bar: ${1:}", "Bar: ${1:int}")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
2019-05-13 14:49:29 -06:00
|
|
|
Foo{Foo{}.B} //@snippet("} ", snipFieldBar, "Bar", "Bar")
|
2019-05-14 20:02:51 -06:00
|
|
|
|
|
|
|
var err error
|
2019-09-17 20:48:41 -06:00
|
|
|
err.Error() //@snippet("E", Error, "Error()", "Error()")
|
|
|
|
f.Baz() //@snippet("B", snipMethodBaz, "Baz()", "Baz()")
|
2019-05-14 20:02:51 -06:00
|
|
|
|
2019-05-17 11:45:59 -06:00
|
|
|
f.Baz() //@snippet("(", snipMethodBazBar, "BazBar", "BazBar")
|
2019-11-22 12:49:12 -07:00
|
|
|
|
|
|
|
f.Baz() //@snippet("B", snipMethodBazBaz, "BazBaz(${1:})", "BazBaz(${1:at AliasType})")
|
2019-04-28 21:19:54 -06:00
|
|
|
}
|