-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x/playground: remove -mod=mod and execute go mod tidy before command
Previously, `-mod=mod` was included to pull down dependencies. This change executes go mod tidy before building packages, that will allow for go work usage, and address golang/go#40728 Fixes golang/go#54741 Change-Id: I66affc8d2a2e72d958415ea1c052dd3dcf38841e Reviewed-on: https://go-review.googlesource.com/c/playground/+/458895 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Commit-Queue: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
- Loading branch information
1 parent
baeddcd
commit 731d161
Showing
4 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
func modTidy(ctx context.Context, dir, goPath string) (output string, execErr error) { | ||
cmd := exec.Command("go", "mod", "tidy") | ||
cmd.Dir = dir | ||
cmd.Env = append(os.Environ(), "CGO_ENABLED=0", "GOPATH="+goPath) | ||
cmd.Env = append(cmd.Env, | ||
"GO111MODULE=on", | ||
"GOPROXY="+playgroundGoproxy(), | ||
) | ||
out, err := cmd.CombinedOutput() | ||
if err == nil { | ||
return "", nil | ||
} | ||
if _, ok := err.(*exec.ExitError); !ok { | ||
return "", fmt.Errorf("error vetting go source: %v", err) | ||
} | ||
|
||
// Rewrite compiler errors to refer to progName | ||
// instead of '/tmp/sandbox1234/main.go'. | ||
errs := strings.Replace(string(out), dir, "", -1) | ||
|
||
return errs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters