Russ Cox | d2cc988 | 2012-02-16 23:50:37 -0500 | [diff] [blame] | 1 | // errorcheck |
Gustavo Niemeyer | daffc2d | 2011-03-02 16:18:17 -0500 | [diff] [blame] | 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 | |
Rob Pike | 501f0b5 | 2012-02-23 18:47:26 +1100 | [diff] [blame] | 7 | // Verify that erroneous use of init is detected. |
| 8 | // Does not compile. |
| 9 | |
Gustavo Niemeyer | daffc2d | 2011-03-02 16:18:17 -0500 | [diff] [blame] | 10 | package main |
| 11 | |
| 12 | import "runtime" |
| 13 | |
| 14 | func init() { |
| 15 | } |
| 16 | |
| 17 | func main() { |
Ian Lance Taylor | d607cb2 | 2011-03-26 11:24:02 -0700 | [diff] [blame] | 18 | init() // ERROR "undefined.*init" |
Gustavo Niemeyer | daffc2d | 2011-03-02 16:18:17 -0500 | [diff] [blame] | 19 | runtime.init() // ERROR "unexported.*runtime\.init" |
Ian Lance Taylor | d607cb2 | 2011-03-26 11:24:02 -0700 | [diff] [blame] | 20 | var _ = init // ERROR "undefined.*init" |
Gustavo Niemeyer | daffc2d | 2011-03-02 16:18:17 -0500 | [diff] [blame] | 21 | } |