Source file test/fixedbugs/bug474.go
1 // run 2 3 // Copyright 2013 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 // Bug in method values: escape analysis was off. 8 9 package main 10 11 import "sync" 12 13 var called = false 14 15 type T struct { 16 once sync.Once 17 } 18 19 func (t *T) M() { 20 called = true 21 } 22 23 func main() { 24 var t T 25 t.once.Do(t.M) 26 if !called { 27 panic("not called") 28 } 29 } 30