modfile: fix trailing empty lines in require blocks

This change ensures that trailing empty lines in `require` blocks
are ignored during parsing itself. Specifically:

- Modified the `parseLineBlock` function to detect and discard blank lines
(represented by a single empty comment) at the end of a block.
- Blank lines within a block are preserved as expected, but trailing
blank lines immediately before the closing parenthesis are now skipped.

For golang/go#70632

Change-Id: Ica76b3edb3bf7fdc327c7cdc9e401dcf19c523b0
GitHub-Last-Rev: 1477d7ce8b79b953be1bf5d7a20d4f9917347299
GitHub-Pull-Request: golang/mod#22
Reviewed-on: https://go-review.googlesource.com/c/mod/+/634875
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 files changed
tree: 25cdb5fec3166fbffed620ae8a7bc406a31781de
  1. gosumcheck/
  2. internal/
  3. modfile/
  4. module/
  5. semver/
  6. sumdb/
  7. zip/
  8. codereview.cfg
  9. go.mod
  10. go.sum
  11. LICENSE
  12. PATENTS
  13. README.md
README.md

mod

PkgGoDev

This repository holds packages for writing tools that work directly with Go module mechanics. That is, it is for direct manipulation of Go modules themselves.

It is NOT about supporting general development tools that need to do things like load packages in module mode. That use case, where modules are incidental rather than the focus, should remain in x/tools, specifically x/tools/go/packages.

The specific case of loading packages should still be done by invoking the go command, which remains the single point of truth for package loading algorithms.