Source file test/makechan.go
1 // errorcheck 2 3 // Copyright 2017 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 // Ensure that typed non-integer, negative and too large 8 // values are not accepted as size argument in make for 9 // channels. 10 11 package main 12 13 type T chan byte 14 15 var sink T 16 17 func main() { 18 sink = make(T, -1) // ERROR "negative buffer argument in make.*|must not be negative" 19 sink = make(T, uint64(1<<63)) // ERROR "buffer argument too large in make.*|overflows int" 20 21 sink = make(T, 0.5) // ERROR "constant 0.5 truncated to integer|truncated to int" 22 sink = make(T, 1.0) 23 sink = make(T, float32(1.0)) // ERROR "non-integer buffer argument in make.*|must be integer" 24 sink = make(T, float64(1.0)) // ERROR "non-integer buffer argument in make.*|must be integer" 25 sink = make(T, 1+0i) 26 sink = make(T, complex64(1+0i)) // ERROR "non-integer buffer argument in make.*|must be integer" 27 sink = make(T, complex128(1+0i)) // ERROR "non-integer buffer argument in make.*|must be integer" 28 } 29