| 1 |
|
| 2 |
-- flags -- |
| 3 |
-ignore_extra_diags |
| 4 |
|
| 5 |
-- go.mod -- |
| 6 |
module mod.test |
| 7 |
|
| 8 |
go 1.18 |
| 9 |
|
| 10 |
-- foo/foo.go -- |
| 11 |
package foo |
| 12 |
|
| 13 |
type StructFoo struct{ F int } |
| 14 |
|
| 15 |
-- a.go -- |
| 16 |
package a |
| 17 |
|
| 18 |
import "mod.test/foo" |
| 19 |
|
| 20 |
func _() { |
| 21 |
StructFoo{} //@item(litStructFoo, "StructFoo{}", "struct{...}", "struct") |
| 22 |
|
| 23 |
var sfp *foo.StructFoo |
| 24 |
// Don't insert the "&" before "StructFoo{}". |
| 25 |
sfp = foo.Str //@snippet(re"() \\/\\/", litStructFoo, "StructFoo{$0\\}") |
| 26 |
|
| 27 |
var sf foo.StructFoo |
| 28 |
sf = foo.Str //@snippet(re"() \\/\\/", litStructFoo, "StructFoo{$0\\}") |
| 29 |
sf = foo. //@snippet(re"() \\/\\/", litStructFoo, "StructFoo{$0\\}") |
| 30 |
} |
| 31 |
|
| 32 |
-- http.go -- |
| 33 |
package a |
| 34 |
|
| 35 |
import ( |
| 36 |
"net/http" |
| 37 |
"sort" |
| 38 |
) |
| 39 |
|
| 40 |
func _() { |
| 41 |
sort.Slice(nil, fun) //@snippet(re"()\\)", litFunc, "func(i, j int) bool {$0\\}") |
| 42 |
|
| 43 |
http.HandleFunc("", f) //@snippet(re"()\\)", litFunc, "func(w http.ResponseWriter, r *http.Request) {$0\\}") |
| 44 |
|
| 45 |
//@item(litFunc, "func(...) {}", "", "var") |
| 46 |
http.HandlerFunc() //@item(handlerFunc, "http.HandlerFunc()", "", "var") |
| 47 |
http.Handle("", http.HandlerFunc()) //@snippet(re"()\\)\\)", litFunc, "func(w http.ResponseWriter, r *http.Request) {$0\\}") |
| 48 |
http.Handle("", h) //@snippet(re"()\\)", handlerFunc, "http.HandlerFunc($0)") |
| 49 |
} |