modfile: copy from cmd/go/internal/modfile

Copied from 4be6b4a73d (CL 202565). No changes other than import paths.

Updates golang/go#34924
Updates golang/go#31761

Change-Id: Ic25cb983f6641045fc24edf76953b06d4aa5cd43
Reviewed-on: https://go-review.googlesource.com/c/mod/+/202543
Reviewed-by: Bryan C. Mills <bcmills@google.com>
19 files changed