cmd/godoc: fix expected test output for Go 1.8 and older

A go/build change in Go 1.9 (CL 33158) allowed for a better expected
error message for "nonexistingpkg" case. CL 37768 did that. However,
that shouldn't be done for Go 1.8 and older, since they don't have
the corresponding go/build change.

So, if the version is Go 1.8 or older, allow matching those previous
expected outputs (before CL 37768) for "nonexistingpkg" case.

Move test cases for TestCLI from a package-level variable into TestCLI
itself. This is more readable, and isGo19's value is ready in time.

Fixes golang/go#20122.

Change-Id: I5e80600a75176d9e54ffebb7730849e381568316
Reviewed-on: https://go-review.googlesource.com/41810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2 files changed