FAQ

On Wed, Sep 12, 2012 at 8:36 PM, Andrew Gerrand wrote:
My intuition suggests that this should probably be a panic instead of
an error return.
Indeed. One tool that uses this function is godoc. This is how it's
affected by issue 3889:

No panic:

% godoc ""
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x1d22e]

goroutine 1 [running]:
main.main()
/Users/f/lib/go/src/cmd/godoc/main.go:353 +0x340e

goroutine 2 [syscall]:
created by runtime.main
/Users/f/lib/go/src/pkg/runtime/proc.c:220

goroutine 14 [runnable]:
text/template/parse.lexText(0xf840185070, 0x1c1da0, 0x397e0, 0xf840185070)
/Users/f/lib/go/src/pkg/text/template/parse/lex.go:227 +0x345
text/template/parse.(*lexer).run(0xf840185070, 0x0)
/Users/f/lib/go/src/pkg/text/template/parse/lex.go:197 +0x3b
created by text/template/parse.lex
/Users/f/lib/go/src/pkg/text/template/parse/lex.go:190 +0x113

With panic:

% godoc ""
panic: Can't import "".

goroutine 1 [running]:
go/build.(*Context).Import(0x5e9050, 0x7fff5fbffa5e, 0xf800000000,
0x3cb95c, 0xf800000000, ...)
/Users/f/lib/go/src/pkg/go/build/build.go:352 +0x63
----- stack segment boundary -----
go/build.Import(0x7fff5fbffa5e, 0x7fff00000000, 0x3cb95c, 0x0,
0xf800000001, ...)
/Users/f/lib/go/src/pkg/go/build/build.go:658 +0x5d
main.main()
/Users/f/lib/go/src/cmd/godoc/main.go:353 +0x33f9

We also could fix godoc to stop ignoring errors returned by
build.Import, but panicking fits too.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 15 | next ›
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 12, '12 at 8:46p
activeSep 13, '12 at 2:34p
posts15
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase