Commit a6736cae authored by Russ Cox's avatar Russ Cox

spec: allow imported packages named main

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
parent 364cb831
<!-- 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>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment