| 1 |
This test exercises function snippets using generics. |
| 2 |
|
| 3 |
-- flags -- |
| 4 |
-ignore_extra_diags |
| 5 |
|
| 6 |
-- settings.json -- |
| 7 |
{ |
| 8 |
"usePlaceholders": true |
| 9 |
} |
| 10 |
|
| 11 |
-- go.mod -- |
| 12 |
module golang.org/lsptests/snippets |
| 13 |
|
| 14 |
go 1.18 |
| 15 |
|
| 16 |
-- funcsnippets.go -- |
| 17 |
package snippets |
| 18 |
|
| 19 |
type SyncMap[K comparable, V any] struct{} |
| 20 |
|
| 21 |
func NewSyncMap[K comparable, V any]() (result *SyncMap[K, V]) { //@item(NewSyncMap, "NewSyncMap", "", "") |
| 22 |
return |
| 23 |
} |
| 24 |
|
| 25 |
func Identity[P ~int](p P) P { //@item(Identity, "Identity", "", "") |
| 26 |
return p |
| 27 |
} |
| 28 |
|
| 29 |
func _() { |
| 30 |
_ = NewSyncM //@snippet(re"() \\/\\/", NewSyncMap, "NewSyncMap[${1:K comparable}, ${2:V any}]()") |
| 31 |
_ = Identi //@snippet(re"() \\/\\/", Identity, "Identity(${1:p P})") |
| 32 |
} |