doc: factor out redirect logic from newPackage to gosrc.MaybeRedirect

This is a refactor to bring the redirect check into a small dedicated
function within gosrc. It can be tested more directly/easily.

Change-Id: Ib9c907bae00384c1f7fef74146b19b715976c546
Reviewed-on: https://go-review.googlesource.com/134475
Reviewed-by: Tuo Shan <shantuo@google.com>
4 files changed