Browse Source

Merge pull request #2 from bketelsen/master

Fix for GOPATH not set
Wirecog 7 years ago
parent
commit
a957e298e4
No account linked to committer's email
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
 }