aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modcmd/edit.go
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2021-03-31 14:47:59 -0400
committerJay Conrod <jayconrod@google.com>2021-04-09 18:20:48 +0000
commit814c5ff13810e800aeb67fd0371e21984d4d2c64 (patch)
treeb11301ba1ae9dacbae011f3e0e1d2fb024025ded /src/cmd/go/internal/modcmd/edit.go
parent952187af12485eb665ae122f6d0bdb36e4a11ed7 (diff)
downloadgo-814c5ff13810e800aeb67fd0371e21984d4d2c64.tar.gz
go-814c5ff13810e800aeb67fd0371e21984d4d2c64.zip
cmd/go: support module deprecation
A module is deprecated if its author adds a comment containing a paragraph starting with "Deprecated:" to its go.mod file. The comment must appear immediately before the "module" directive or as a suffix on the same line. The deprecation message runs from just after "Deprecated:" to the end of the paragraph. This is implemented in CL 301089. 'go list -m -u' loads deprecation messages from the latest version of each module, not considering retractions (i.e., deprecations and retractions are loaded from the same version). By default, deprecated modules are printed with a "(deprecated)" suffix. The full deprecation message is available in the -f and -json output. 'go get' prints deprecation warnings for modules named on the command line. It also prints warnings for modules needed to build packages named on the command line if those modules are direct dependencies of the main module. For #40357 Change-Id: Id81fb2b24710681b025becd6cd74f746f4378e78 Reviewed-on: https://go-review.googlesource.com/c/go/+/306334 Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modcmd/edit.go')
-rw-r--r--src/cmd/go/internal/modcmd/edit.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/cmd/go/internal/modcmd/edit.go b/src/cmd/go/internal/modcmd/edit.go
index 1df104eb1d..e1ec088f55 100644
--- a/src/cmd/go/internal/modcmd/edit.go
+++ b/src/cmd/go/internal/modcmd/edit.go
@@ -86,7 +86,7 @@ writing it back to go.mod. The JSON output corresponds to these Go types:
type Module struct {
Path string
- Version string
+ Deprecated string
}
type GoMod struct {
@@ -450,7 +450,7 @@ func flagDropRetract(arg string) {
// fileJSON is the -json output data structure.
type fileJSON struct {
- Module module.Version
+ Module editModuleJSON
Go string `json:",omitempty"`
Require []requireJSON
Exclude []module.Version
@@ -458,6 +458,11 @@ type fileJSON struct {
Retract []retractJSON
}
+type editModuleJSON struct {
+ Path string
+ Deprecated string `json:",omitempty"`
+}
+
type requireJSON struct {
Path string
Version string `json:",omitempty"`
@@ -479,7 +484,10 @@ type retractJSON struct {
func editPrintJSON(modFile *modfile.File) {
var f fileJSON
if modFile.Module != nil {
- f.Module = modFile.Module.Mod
+ f.Module = editModuleJSON{
+ Path: modFile.Module.Mod.Path,
+ Deprecated: modFile.Module.Deprecated,
+ }
}
if modFile.Go != nil {
f.Go = modFile.Go.Version