1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:04:45 -07:00

Revert "godoc: use "IsPredeclared" of go/doc"

This reverts commit 144c6642b5.

Reason for revert: Breaks Go 1.7 and below.

See https://go-review.googlesource.com/c/43473/

Change-Id: I06ff6e9dccb842e29389af6beb67d6cdc217fb98
Reviewed-on: https://go-review.googlesource.com/43496
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
This commit is contained in:
Brad Fitzpatrick 2017-05-15 17:12:53 +00:00
parent 144c6642b5
commit bf4b54dc68

View File

@ -13,7 +13,6 @@ package godoc
import (
"fmt"
"go/ast"
"go/doc"
"go/token"
"io"
"strconv"
@ -183,7 +182,7 @@ func linksFor(node ast.Node) (links []link) {
links = append(links, l)
} else {
l := link{name: n.Name}
if n.Obj == nil && doc.IsPredeclared(n.Name) {
if n.Obj == nil && predeclared[n.Name] {
l.path = builtinPkgPath
}
links = append(links, l)
@ -193,3 +192,49 @@ func linksFor(node ast.Node) (links []link) {
})
return
}
// The predeclared map represents the set of all predeclared identifiers.
// TODO(gri) This information is also encoded in similar maps in go/doc,
// but not exported. Consider exporting an accessor and using
// it instead.
var predeclared = map[string]bool{
"bool": true,
"byte": true,
"complex64": true,
"complex128": true,
"error": true,
"float32": true,
"float64": true,
"int": true,
"int8": true,
"int16": true,
"int32": true,
"int64": true,
"rune": true,
"string": true,
"uint": true,
"uint8": true,
"uint16": true,
"uint32": true,
"uint64": true,
"uintptr": true,
"true": true,
"false": true,
"iota": true,
"nil": true,
"append": true,
"cap": true,
"close": true,
"complex": true,
"copy": true,
"delete": true,
"imag": true,
"len": true,
"make": true,
"new": true,
"panic": true,
"print": true,
"println": true,
"real": true,
"recover": true,
}