cmd/go/internal/modload: remove printStackInDie functionality

Previously, when running cmd/go tests, if the module root directory is
requested when modules are explicitly disabled, we printed a stack
trace in addition to the error message that's normally printed. The
stack trace isn't that useful, and it makes the actual error hard to
find.

Change-Id: I8230d668f3f16659f08d0d685124c41b4055c5b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/263659
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Jay Conrod 2020-10-19 14:02:14 -04:00
parent 1b09d43067
commit e2c420591c
3 changed files with 0 additions and 25 deletions

View File

@ -13,7 +13,6 @@ import (
"internal/goroot" "internal/goroot"
"os" "os"
"path/filepath" "path/filepath"
"runtime/debug"
"strings" "strings"
"cmd/go/internal/base" "cmd/go/internal/base"
@ -312,9 +311,6 @@ func mustFindModule(target, path string) module.Version {
return Target return Target
} }
if printStackInDie {
debug.PrintStack()
}
base.Fatalf("build %v: cannot find module for path %v", target, path) base.Fatalf("build %v: cannot find module for path %v", target, path)
panic("unreachable") panic("unreachable")
} }

View File

@ -16,7 +16,6 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
@ -330,16 +329,7 @@ func ModFilePath() string {
return filepath.Join(modRoot, "go.mod") return filepath.Join(modRoot, "go.mod")
} }
// printStackInDie causes die to print a stack trace.
//
// It is enabled by the testgo tag, and helps to diagnose paths that
// unexpectedly require a main module.
var printStackInDie = false
func die() { func die() {
if printStackInDie {
debug.PrintStack()
}
if cfg.Getenv("GO111MODULE") == "off" { if cfg.Getenv("GO111MODULE") == "off" {
base.Fatalf("go: modules disabled by GO111MODULE=off; see 'go help modules'") base.Fatalf("go: modules disabled by GO111MODULE=off; see 'go help modules'")
} }

View File

@ -1,11 +0,0 @@
// Copyright 2018 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.
// +build testgo
package modload
func init() {
printStackInDie = true
}