[dev.cmdgo] modfile: parser changes for workfile proposal

This change adds interfaces to the mod package to support parsing
and representing go.work files, including WorkFile for the file as a
whole, Directory for directory statements, and ParseWork for parsing
go.work files.

This code is mostly a lightly modified version of the parsing
code for mod files.

This is meant to support the workspaces proposal and if the proposal
is accepted it's expected theinterface will likely change.

For #45713

Change-Id: I5df6fe4acba1dbe86bc3e3fba40a04fbb4d678e4
Reviewed-on: https://go-review.googlesource.com/c/mod/+/336089
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit e41a6a4f3b61149dd5d84af28eaf4278710af3cb)
Reviewed-on: https://go-review.googlesource.com/c/mod/+/324764
Reviewed-by: Bryan C. Mills <bcmills@google.com>
14 files changed
tree: 39b782fb701f65d3c53e265a78cd3358312ce9a7
  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.