Browse Source

This change accounts for a GOPATH that isn't set, but relies on the new defaulted GOPATH.

Brian Ketelsen 6 years ago
parent
commit
ca65c95c84
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      cog.go

+ 9
- 1
cog.go View File

6
 package cog
6
 package cog
7
 
7
 
8
 import (
8
 import (
9
+	"go/build"
9
 	"os"
10
 	"os"
10
 )
11
 )
11
 
12
 
22
 
23
 
23
 func init() {
24
 func init() {
24
 
25
 
26
+	var gopath string
27
+	gp := os.Getenv("GOPATH")
28
+	if gp != "" {
29
+		gopath = gp
30
+	} else {
31
+		gopath = build.Default.GOPATH
32
+	}
25
 	DefaultTemplatesDirectoryName = "templates"
33
 	DefaultTemplatesDirectoryName = "templates"
26
-	DefaultGoSourcePath = os.Getenv("GOPATH") + "/src"
34
+	DefaultGoSourcePath = gopath + "/src"
27
 
35
 
28
 }
36
 }