mirror of
https://github.com/golang/go
synced 2024-11-19 03:34:41 -07:00
473961ec04
Now that we understand object "kind" for builtin generic functions, we can apply it to a couple more places as well: // prefer rangeable object kinds for i := range <> { } // prefer channels <- <> Change-Id: If9cfba3a06b3abde073a9d397000bb3f3b0e9853 Reviewed-on: https://go-review.googlesource.com/c/tools/+/214678 Run-TryBot: Muir Manders <muir@mnd.rs> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
46 lines
2.1 KiB
Go
46 lines
2.1 KiB
Go
package builtins
|
|
|
|
func _() {
|
|
var (
|
|
aSlice []int //@item(builtinSlice, "aSlice", "[]int", "var")
|
|
aMap map[string]int //@item(builtinMap, "aMap", "map[string]int", "var")
|
|
aString string //@item(builtinString, "aString", "string", "var")
|
|
aArray [0]int //@item(builtinArray, "aArray", "[0]int", "var")
|
|
aArrayPtr *[0]int //@item(builtinArrayPtr, "aArrayPtr", "*[0]int", "var")
|
|
aChan chan int //@item(builtinChan, "aChan", "chan int", "var")
|
|
aPtr *int //@item(builtinPtr, "aPtr", "*int", "var")
|
|
aInt int //@item(builtinInt, "aInt", "int", "var")
|
|
)
|
|
|
|
close() //@rank(")", builtinChan, builtinSlice)
|
|
|
|
append() //@rank(")", builtinSlice, builtinChan)
|
|
|
|
copy() //@rank(")", builtinSlice, builtinChan)
|
|
copy(aSlice, aS) //@rank(")", builtinSlice, builtinString)
|
|
copy(aS, aSlice) //@rank(",", builtinSlice, builtinString)
|
|
|
|
delete() //@rank(")", builtinMap, builtinChan)
|
|
delete(aMap, aS) //@rank(")", builtinString, builtinSlice)
|
|
|
|
len() //@rank(")", builtinSlice, builtinInt),rank(")", builtinMap, builtinInt),rank(")", builtinString, builtinInt),rank(")", builtinArray, builtinInt),rank(")", builtinArrayPtr, builtinPtr),rank(")", builtinChan, builtinInt)
|
|
|
|
cap() //@rank(")", builtinSlice, builtinMap),rank(")", builtinArray, builtinString),rank(")", builtinArrayPtr, builtinPtr),rank(")", builtinChan, builtinInt)
|
|
|
|
make() //@rank(")", builtinMap, builtinInt),rank(")", builtinChan, builtinInt),rank(")", builtinSlice, builtinInt)
|
|
|
|
var _ []int = make() //@rank(")", builtinSlice, builtinMap)
|
|
|
|
type myStruct struct{} //@item(builtinStructType, "myStruct", "struct{...}", "struct")
|
|
new() //@rank(")", builtinStructType, builtinInt)
|
|
var _ *myStruct = new() //@rank(")", builtinStructType, int)
|
|
|
|
for k := range a { //@rank(" {", builtinSlice, builtinInt),rank(" {", builtinString, builtinInt),rank(" {", builtinChan, builtinInt),rank(" {", builtinArray, builtinInt),rank(" {", builtinArrayPtr, builtinInt),rank(" {", builtinMap, builtinInt),
|
|
}
|
|
|
|
for k, v := range a { //@rank(" {", builtinSlice, builtinChan)
|
|
}
|
|
|
|
<-a //@rank(" //", builtinChan, builtinInt)
|
|
}
|