aboutsummaryrefslogtreecommitdiff
path: root/test/init.go
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2011-03-02 16:18:17 -0500
committerRuss Cox <rsc@golang.org>2011-03-02 16:18:17 -0500
commitdaffc2d2ef1b68eae0a7e79d015fe33339f19534 (patch)
tree628224fbc772bd6d34275fab33fb3aeba28cdf5a /test/init.go
parentff1d89d6003272585093cfbab630c534fbba69bd (diff)
downloadgo-daffc2d2ef1b68eae0a7e79d015fe33339f19534.tar.gz
go-daffc2d2ef1b68eae0a7e79d015fe33339f19534.zip
gc: fix init of packages named main
This change removes the special case which existed for handling the initalization of the main package, so that other modules named 'main' get properly initialized when imported. Note that gotest of main packages will break in most cases without this. R=rsc CC=golang-dev https://golang.org/cl/4190050
Diffstat (limited to 'test/init.go')
-rw-r--r--test/init.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/init.go b/test/init.go
new file mode 100644
index 0000000000..b6c8c97063
--- /dev/null
+++ b/test/init.go
@@ -0,0 +1,18 @@
+// errchk $G -e $D/$F.go
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "runtime"
+
+func init() {
+}
+
+func main() {
+ init() // ERROR "undefined: init"
+ runtime.init() // ERROR "unexported.*runtime\.init"
+ var _ = init // ERROR "undefined: init"
+}