From e2c420591cbbd684594a111fa5cdeb40c68964a5 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Mon, 19 Oct 2020 14:02:14 -0400 Subject: [PATCH] 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 Run-TryBot: Jay Conrod TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/modload/build.go | 4 ---- src/cmd/go/internal/modload/init.go | 10 ---------- src/cmd/go/internal/modload/testgo.go | 11 ----------- 3 files changed, 25 deletions(-) delete mode 100644 src/cmd/go/internal/modload/testgo.go diff --git a/src/cmd/go/internal/modload/build.go b/src/cmd/go/internal/modload/build.go index f49b52df56..b9abb0b93c 100644 --- a/src/cmd/go/internal/modload/build.go +++ b/src/cmd/go/internal/modload/build.go @@ -13,7 +13,6 @@ import ( "internal/goroot" "os" "path/filepath" - "runtime/debug" "strings" "cmd/go/internal/base" @@ -312,9 +311,6 @@ func mustFindModule(target, path string) module.Version { return Target } - if printStackInDie { - debug.PrintStack() - } base.Fatalf("build %v: cannot find module for path %v", target, path) panic("unreachable") } diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go index e1b784860b..1fcc53735c 100644 --- a/src/cmd/go/internal/modload/init.go +++ b/src/cmd/go/internal/modload/init.go @@ -16,7 +16,6 @@ import ( "os" "path" "path/filepath" - "runtime/debug" "strconv" "strings" @@ -330,16 +329,7 @@ func ModFilePath() string { 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'") } diff --git a/src/cmd/go/internal/modload/testgo.go b/src/cmd/go/internal/modload/testgo.go deleted file mode 100644 index 6b34f5be39..0000000000 --- a/src/cmd/go/internal/modload/testgo.go +++ /dev/null @@ -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 -} -- 2.50.0