]> Cypherpunks repositories - gostls13.git/commitdiff
spec: allow imported packages named main
authorRuss Cox <rsc@golang.org>
Thu, 3 Feb 2011 18:40:51 +0000 (13:40 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 3 Feb 2011 18:40:51 +0000 (13:40 -0500)
Prior to this CL, there were two requirements about the
package name main.

1. The package that sits at the root of the import graph
   (the one where program execution begins)
   must be named main.

2. No other package in the program can be named main.

This CL only removes requirement #2, which can be done
without changing any other Go documentation.

The new wording and formatting is such that removing
requirement #1 can be done by deleting a single line,
but making that change is explicitly outside the scope
of this CL, because it would require changes to other
documentation at the same time.

R=gri, r, gri1
CC=golang-dev
https://golang.org/cl/4126053

doc/go_spec.html

index 4e5d9c639bc5aea683a5f4bd8adf7299c6e012d1..a861f0cbf66870e592041b2e1b0fe251a842f57d 100644 (file)
@@ -1,5 +1,5 @@
 <!-- title The Go Programming Language Specification -->
-<!-- subtitle Version of February 1, 2011 -->
+<!-- subtitle Version of February 3, 2011 -->
 
 <!--
 TODO
@@ -5064,8 +5064,12 @@ The importing of packages, by construction, guarantees that there can
 be no cyclic dependencies in initialization.
 </p>
 <p>
-A complete program, possibly created by linking multiple packages,
-must have one package called <code>main</code>, with a function
+A complete program is created by linking a single, unimported package
+called the <i>main package</i> with all the packages it imports, transitively.
+The main package must
+have package name <code>main</code> and
+declare a function <code>main</code> that takes no 
+arguments and returns no value.
 </p>
 
 <pre>
@@ -5073,20 +5077,12 @@ func main() { ... }
 </pre>
 
 <p>
-defined.
-The function <code>main.main()</code> takes no arguments and returns no value.
+Program execution begins by initializing the main package and then
+invoking the function <code>main</code>.
 </p>
 <p>
-Program execution begins by initializing the <code>main</code> package and then
-invoking <code>main.main()</code>.
-</p>
-<p>
-When <code>main.main()</code> returns, the program exits.  It does not wait for
-other (non-<code>main</code>) goroutines to complete.
-</p>
-<p>
-Implementation restriction: The compiler assumes package <code>main</code>
-is not imported by any other package.
+When the function <code>main</code> returns, the program exits.
+It does not wait for other (non-<code>main</code>) goroutines to complete.
 </p>
 
 <h2 id="Run_time_panics">Run-time panics</h2>