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 @@ -12,6 +12,11 @@ env HOME=
12
12
! go build -o triv triv.go
13
13
stderr 'build cache is required, but could not be located: GOCACHE is not defined and .*'
14
14
15
+ # If GOCACHE is set but is not an absolute path, and we cannot build.
16
+ env GOCACHE=test
17
+ ! go build -o triv triv.go
18
+ stderr 'build cache is required, but could not be located: GOCACHE is not an absolute path'
19
+
15
20
# An explicit GOCACHE=off also disables builds.
16
21
env GOCACHE=off
17
22
! go build -o triv triv.go
You can’t perform that action at this time.
0 commit comments