diff --git a/doc/go_spec.html b/doc/go_spec.html index 4255fec42b2..46b9eb6f861 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -4176,23 +4176,12 @@ An implementation may require that all source files for a package inhabit the sa
-An import declaration states that the current package depends on the -imported package and provides acccess to its -exported identifiers. -
- -
-The import declaration binds a package name to the imported package (except in
-the case of .
or _
imports; see below). The package name
-denotes the imported package within the current source file. If no explicit
-package name is present, the package name defined within the source
-files of the imported package is used.
-
-The imported package is specified by an import path; the meaning of the path -is implementation-dependent. It may be a file name relative to a repository -of installed packages and the file a (compiled) implementation of the package. +An import declaration states that the source file containing the +declaration uses identifiers +exported by the imported +package and enables access to them. The import names an +identifier (PackageName) to be used for access and an ImportPath +that specifies the package to be imported.
@@ -4203,22 +4192,30 @@ ImportPath = StringLit .
-If a package A
is imported by a package P
and
-A
exports an identifier X
, then X
-may be referred to by the qualified identifier
-A.X
within P
. If an explicit package name
-B
is present, X
must be referred to as B.X
.
-Finally, if the import declaration uses an explicit period
-(.
) for the package name, X
will be declared
-in the current file's file block and can be accessed
-without a qualifier.
+The PackageName is used in qualified identifiers
+to access the exported identifiers of the package within the importing source file.
+It is declared in the file block.
+If the PackageName is omitted, it defaults to the identifier specified in the
+package clause of the imported package.
+If an explicit period (.
) appears instead of a name, all the
+package's exported identifiers will be declared in the current file's
+file block and can be accessed without a qualifier.
-In this table, assume we have compiled a package named
-math
, which exports function Sin
, and
-installed the compiled package in file
+The interpretation of the ImportPath is implementation-dependent but
+it is typically a substring of the full file name of the compiled
+package and may be relative to a repository of installed packages.
+
+Assume we have compiled a package containing the package clause
+package math
, which exports function Sin
, and
+installed the compiled package in the file identified by
"lib/math"
.
+This table illustrates how Sin
may be accessed in files
+that import the package after the
+various types of import declaration.
@@ -4230,6 +4227,8 @@ import . "lib/math" Sin
+An import declaration declares a dependency relation between +the importing and imported package. It is illegal for a package to import itself or to import a package without referring to any of its exported identifiers. To import a package solely for its side-effects (initialization), use the blank