Commit 1a427a69 authored by Robert Griesemer's avatar Robert Griesemer

cmd/godoc: don't crash if there's no documentation

Fixes regression introduced by CL 7860049.

R=golang-dev, kamil.kisiel, dave
CC=golang-dev
https://golang.org/cl/8069044
parent ab962c8d
...@@ -388,12 +388,12 @@ func main() { ...@@ -388,12 +388,12 @@ func main() {
} }
// determine what to use // determine what to use
if info.IsEmpty() { if info == nil || info.IsEmpty() {
if !cinfo.IsEmpty() { if cinfo != nil && !cinfo.IsEmpty() {
// only cinfo exists - switch to cinfo // only cinfo exists - switch to cinfo
info = cinfo info = cinfo
} }
} else if !cinfo.IsEmpty() { } else if cinfo != nil && !cinfo.IsEmpty() {
// both info and cinfo exist - use cinfo if info // both info and cinfo exist - use cinfo if info
// contains only subdirectory information // contains only subdirectory information
if info.PAst == nil && info.PDoc == nil { if info.PAst == nil && info.PDoc == nil {
...@@ -403,9 +403,13 @@ func main() { ...@@ -403,9 +403,13 @@ func main() {
} }
} }
if info == nil {
log.Fatalf("%s: no such directory or package", flag.Arg(0))
}
if info.Err != nil { if info.Err != nil {
log.Fatalf("%v", info.Err) log.Fatalf("%v", info.Err)
} }
if info.PDoc != nil && info.PDoc.ImportPath == target { if info.PDoc != nil && info.PDoc.ImportPath == target {
// Replace virtual /target with actual argument from command line. // Replace virtual /target with actual argument from command line.
info.PDoc.ImportPath = flag.Arg(0) info.PDoc.ImportPath = flag.Arg(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment