mirror of
https://github.com/golang/go
synced 2024-11-18 23:05:06 -07:00
62a9628863
In the upcoming Go 1.14 release, there is an introduction of the -modfile flag which allows a user to run a go command but choose where to direct the go.mod file updates. The information about this can be found here: golang/go#34506. This change starts setting up the infrastructure to handle the seperate modfile rather than keep changing a user's go.mod file. To support versions of Go that are not 1.14, we run a modified "go list" command that checks the release tags to see if 1.14 is contained. Updates golang/go#31999 Change-Id: Icb71b6402ec4fa07e5f6f1a63954c25520e860b0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/211538 Run-TryBot: Rohan Challa <rohan@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
18 lines
457 B
Go
18 lines
457 B
Go
package source
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
func ModTidy(ctx context.Context, view View) error {
|
|
cfg := view.Config(ctx)
|
|
|
|
// Running `go mod tidy` modifies the file on disk directly.
|
|
// Ideally, we should return modules that could possibly be removed
|
|
// and apply each action as an edit.
|
|
//
|
|
// TODO(rstambler): This will be possible when golang/go#27005 is resolved.
|
|
_, err := InvokeGo(ctx, view.Folder().Filename(), cfg.Env, "mod", "tidy")
|
|
return err
|
|
}
|