| 1 |
// run |
| 2 |
|
| 3 |
// Copyright 2009 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 |
package main |
| 8 |
|
| 9 |
var m = map[int]int{0: 0, 1: 0} |
| 10 |
var nf = 0 |
| 11 |
var i int |
| 12 |
|
| 13 |
func multi() (int, int) { return 1, 2 } |
| 14 |
|
| 15 |
func xxx() { |
| 16 |
var c chan int |
| 17 |
x, ok := <-c |
| 18 |
|
| 19 |
var m map[int]int |
| 20 |
x, ok = m[1] |
| 21 |
|
| 22 |
var i interface{} |
| 23 |
var xx int |
| 24 |
xx, ok = i.(int) |
| 25 |
|
| 26 |
a, b := multi() |
| 27 |
|
| 28 |
_, _, _, _, _ = x, ok, xx, a, b |
| 29 |
} |
| 30 |
|
| 31 |
func f() map[int]int { |
| 32 |
nf++ |
| 33 |
return m |
| 34 |
} |
| 35 |
|
| 36 |
func g() *int { |
| 37 |
nf++ |
| 38 |
return &i |
| 39 |
} |
| 40 |
|
| 41 |
func main() { |
| 42 |
f()[0]++ |
| 43 |
f()[1] += 2 |
| 44 |
*g() %= 2 |
| 45 |
if nf != 3 { |
| 46 |
println("too many calls:", nf) |
| 47 |
panic("fail") |
| 48 |
} |
| 49 |
|
| 50 |
} |