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>
"internal/goroot"
"os"
"path/filepath"
- "runtime/debug"
"strings"
"cmd/go/internal/base"
return Target
}
- if printStackInDie {
- debug.PrintStack()
- }
base.Fatalf("build %v: cannot find module for path %v", target, path)
panic("unreachable")
}
"os"
"path"
"path/filepath"
- "runtime/debug"
"strconv"
"strings"
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() {
- if printStackInDie {
- debug.PrintStack()
- }
if cfg.Getenv("GO111MODULE") == "off" {
base.Fatalf("go: modules disabled by GO111MODULE=off; see 'go help modules'")
}
+++ /dev/null
-// 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
-}