]> Cypherpunks.ru repositories - gostls13.git/commit
gc: disallow absolute import paths
authorRuss Cox <rsc@golang.org>
Wed, 29 Feb 2012 20:28:36 +0000 (15:28 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 29 Feb 2012 20:28:36 +0000 (15:28 -0500)
commitd0d251f858efa75fc67ab8804413edfec57cc2db
treec96527fce3a960de67ae2409ac85d52d01a4a002
parent0201e373e5d0ed98a9ee3c8dbcacae4bf2ffd2cb
gc: disallow absolute import paths

They are broken and hard to make work.

They have never worked: if you import "/tmp/x"
from "/home/rsc/p.c" then the compiler rewrites
this into import "/home/rsc/tmp/x", which is
clearly wrong.

Also we just disallowed the : character in import
paths, so import "c:/foo" is already not allowed.

Finally, in order to support absolute paths well in
a build tool we'd have to provide a mechanism to
instruct the compiler to resolve absolute imports
by looking in some other tree (where the binaries live)
and provide a mapping from absolute path to location
in that tree.  This CL avoids adding that complexity.

This is not part of the language spec (and should not be),
so no spec change is needed.

If we need to make them work later, we can.

R=ken2
CC=golang-dev
https://golang.org/cl/5712043
src/cmd/gc/lex.c
test/import5.go