2019-04-28 21:19:54 -06:00
|
|
|
package snippets
|
|
|
|
|
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-04-28 21:19:54 -06:00
|
|
|
|
|
|
|
type Foo struct {
|
|
|
|
Bar int //@item(snipFieldBar, "Bar", "int", "field")
|
|
|
|
}
|
|
|
|
|
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-04-28 21:19:54 -06:00
|
|
|
|
|
|
|
func _() {
|
2019-05-13 14:49:29 -06:00
|
|
|
f //@snippet(" //", snipFoo, "foo(${1})", "foo(${1:i int}, ${2:b bool})")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
2019-05-13 14:49:29 -06:00
|
|
|
bar //@snippet(" //", snipBar, "bar(${1})", "bar(${1:fn func()})")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
2019-05-17 11:45:59 -06:00
|
|
|
bar(nil) //@snippet("(", snipBar, "bar", "bar")
|
2019-05-13 14:49:29 -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-05-13 21:09:27 -06:00
|
|
|
(bar)(nil) //@snippet(")", snipBar, "bar(${1})", "bar(${1:fn func()})")
|
|
|
|
(f.Ba)() //@snippet(")", snipMethodBaz, "Baz()", "Baz()")
|
2019-04-28 21:19:54 -06:00
|
|
|
|
|
|
|
Foo{
|
2019-05-13 14:49:29 -06:00
|
|
|
B //@snippet(" //", snipFieldBar, "Bar: ${1},", "Bar: ${1:int},")
|
2019-04-28 21:19:54 -06:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:49:29 -06:00
|
|
|
Foo{B} //@snippet("}", snipFieldBar, "Bar: ${1}", "Bar: ${1:int}")
|
2019-04-28 21:19:54 -06:00
|
|
|
Foo{} //@snippet("}", snipFieldBar, "Bar: ${1}", "Bar: ${1:int}")
|
|
|
|
|
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-05-17 11:45:59 -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-04-28 21:19:54 -06:00
|
|
|
}
|