summaryrefslogtreecommitdiff
path: root/src/cmd/godoc/godoc.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/godoc/godoc.go')
-rw-r--r--src/cmd/godoc/godoc.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go
index 4fe628fb5..688806c42 100644
--- a/src/cmd/godoc/godoc.go
+++ b/src/cmd/godoc/godoc.go
@@ -213,19 +213,21 @@ func nodeText(node interface{}) []byte {
// Convert x, whatever it is, to text form.
func toText(x interface{}) []byte {
- type String interface { String() string }
+ type Stringer interface { String() string }
switch v := x.(type) {
case []byte:
return v;
case string:
return strings.Bytes(v);
- case String:
- return strings.Bytes(v.String());
case ast.Decl:
return nodeText(v);
case ast.Expr:
return nodeText(v);
+ case Stringer:
+ // last resort (AST nodes get a String method
+ // from token.Position - don't call that one)
+ return strings.Bytes(v.String());
}
var buf bytes.Buffer;
fmt.Fprint(&buf, x);