1
0
mirror of https://github.com/golang/go synced 2024-11-06 14:36:22 -07:00

cmd/doc: minor code simplification

Follow-up on https://golang.org/cl/143037.

Change-Id: Ia36760b499f7d46ce03e0fa81ec455a4a20208ac
Reviewed-on: https://go-review.googlesource.com/c/143061
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Robert Griesemer 2018-10-18 12:37:25 -07:00
parent fa31093ec4
commit 2d6a7593b5

View File

@ -207,17 +207,15 @@ func (pkg *Package) newlines(n int) {
// clears the stuff we don't want to print anyway. It's a bit of a magic trick.
func (pkg *Package) emit(comment string, node ast.Node) {
if node != nil {
var err error
var arg interface{} = node
if showSrc {
// Need an extra little dance to get internal comments to appear.
commentedNode := &printer.CommentedNode{
arg = &printer.CommentedNode{
Node: node,
Comments: pkg.file.Comments,
}
err = format.Node(&pkg.buf, pkg.fs, commentedNode)
} else {
err = format.Node(&pkg.buf, pkg.fs, node)
}
err := format.Node(&pkg.buf, pkg.fs, arg)
if err != nil {
log.Fatal(err)
}