[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>
14 files changed
tree: a24ec15795ec9714b675807320475ea759a0d165
  1. gosumcheck/
  2. internal/
  3. modfile/
  4. module/
  5. semver/
  6. sumdb/
  7. zip/
  8. codereview.cfg
  9. go.mod
  10. go.sum
  13. README.md



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.