From 7c3349a337156d6e9200fb7960bd300c3a6f2dce Mon Sep 17 00:00:00 2001 From: Yutian Li Date: Wed, 27 Jul 2016 21:02:30 +0800 Subject: [PATCH 1/2] [master] Special treatment for "C" package. --- go/parser/parser.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go/parser/parser.go b/go/parser/parser.go index b6bfef7..69e4cfe 100644 --- a/go/parser/parser.go +++ b/go/parser/parser.go @@ -1967,6 +1967,9 @@ func parseImportSpec(p *parser, doc *ast.CommentGroup, decl *ast.GenDecl, _ int) if declIdent == nil { filename := p.fset.Position(path.Pos()).Filename name, err := p.pathToName(litToString(path), filepath.Dir(filename)) + if litToString(path) == "C" { + name = "C" + } if name == "" { p.error(path.Pos(), fmt.Sprintf("cannot find identifier for package %q: %v", litToString(path), err)) } else { From d56474040fe2f23c1a3612ed550c5c5ce389d384 Mon Sep 17 00:00:00 2001 From: Yutian Li Date: Wed, 28 Sep 2016 11:57:51 +0800 Subject: [PATCH 2/2] [master] Only set C if name is empty. --- go/parser/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/parser/parser.go b/go/parser/parser.go index 69e4cfe..0bbc30d 100644 --- a/go/parser/parser.go +++ b/go/parser/parser.go @@ -1967,7 +1967,7 @@ func parseImportSpec(p *parser, doc *ast.CommentGroup, decl *ast.GenDecl, _ int) if declIdent == nil { filename := p.fset.Position(path.Pos()).Filename name, err := p.pathToName(litToString(path), filepath.Dir(filename)) - if litToString(path) == "C" { + if name == "" && litToString(path) == "C" { name = "C" } if name == "" {