1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:44:40 -07:00

gc: diagnose \ in import path

R=ken2
CC=golang-dev
https://golang.org/cl/5609044
This commit is contained in:
Russ Cox 2012-01-31 17:29:59 -05:00
parent 6aa6fdcf71
commit 33f3afa7af
2 changed files with 16 additions and 0 deletions

View File

@ -575,6 +575,11 @@ importfile(Val *f, int line)
errorexit();
}
if(strchr(f->u.sval->s, '\\')) {
yyerror("import path contains backslash; use slash");
errorexit();
}
// The package name main is no longer reserved,
// but we reserve the import path "main" to identify
// the main package, just as we reserve the import

11
test/import5.go Normal file
View File

@ -0,0 +1,11 @@
// errchk $G -e $D/$F.go
// Copyright 2009 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.
// import paths are slash-separated; reject backslash
package main
import `net\http` // ERROR "backslash"