File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ See golang.org to learn more about Go.
37
37
// the first time Default is called.
38
38
func initDefaultCache () {
39
39
dir := DefaultDir ()
40
- if dir == "off" || dir == "" {
40
+ if dir == "off" {
41
41
if defaultDirErr != nil {
42
42
base .Fatalf ("build cache is required, but could not be located: %v" , defaultDirErr )
43
43
}
@@ -74,7 +74,12 @@ func DefaultDir() string {
74
74
75
75
defaultDirOnce .Do (func () {
76
76
defaultDir = os .Getenv ("GOCACHE" )
77
+ if filepath .IsAbs (defaultDir ) || defaultDir == "off" {
78
+ return
79
+ }
77
80
if defaultDir != "" {
81
+ defaultDir = "off"
82
+ defaultDirErr = fmt .Errorf ("GOCACHE is not an absolute path" )
78
83
return
79
84
}
80
85
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ env HOME=
10
10
! go build -o triv triv.go
11
11
stderr 'build cache is required, but could not be located: GOCACHE is not defined and .*'
12
12
13
+ # If GOCACHE is set but is not an absolute path, and we cannot build.
14
+ env GOCACHE=test
15
+ ! go build -o triv triv.go
16
+ stderr 'build cache is required, but could not be located: GOCACHE is not an absolute path'
17
+
13
18
# An explicit GOCACHE=off also disables builds.
14
19
env GOCACHE=off
15
20
! go build -o triv triv.go
You can’t perform that action at this time.
0 commit comments