github.com/akaros/go-akaros@v0.0.0-20181004170632-85005d477eab/test/map1.go (about) 1 // errorcheck 2 3 // Copyright 2011 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Test map declarations of many types, including erroneous ones. 8 // Does not compile. 9 10 package main 11 12 func main() {} 13 14 type v bool 15 16 var ( 17 // valid 18 _ map[int8]v 19 _ map[uint8]v 20 _ map[int16]v 21 _ map[uint16]v 22 _ map[int32]v 23 _ map[uint32]v 24 _ map[int64]v 25 _ map[uint64]v 26 _ map[int]v 27 _ map[uint]v 28 _ map[uintptr]v 29 _ map[float32]v 30 _ map[float64]v 31 _ map[complex64]v 32 _ map[complex128]v 33 _ map[bool]v 34 _ map[string]v 35 _ map[chan int]v 36 _ map[*int]v 37 _ map[struct{}]v 38 _ map[[10]int]v 39 40 // invalid 41 _ map[[]int]v // ERROR "invalid map key" 42 _ map[func()]v // ERROR "invalid map key" 43 _ map[map[int]int]v // ERROR "invalid map key" 44 _ map[T1]v // ERROR "invalid map key" 45 _ map[T2]v // ERROR "invalid map key" 46 _ map[T3]v // ERROR "invalid map key" 47 _ map[T4]v // ERROR "invalid map key" 48 _ map[T5]v 49 _ map[T6]v 50 _ map[T7]v 51 _ map[T8]v 52 ) 53 54 type T1 []int 55 type T2 struct { F T1 } 56 type T3 []T4 57 type T4 struct { F T3 } 58 59 type T5 *int 60 type T6 struct { F T5 } 61 type T7 *T4 62 type T8 struct { F *T7 }