Browse Source

Merge pull request #2 from bketelsen/master

Fix for GOPATH not set
Wirecog 6 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,6 +6,7 @@
6 6
 package cog
7 7
 
8 8
 import (
9
+	"go/build"
9 10
 	"os"
10 11
 )
11 12
 
@@ -22,7 +23,14 @@ type Cog interface {
22 23
 
23 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 33
 	DefaultTemplatesDirectoryName = "templates"
26
-	DefaultGoSourcePath = os.Getenv("GOPATH") + "/src"
34
+	DefaultGoSourcePath = gopath + "/src"
27 35
 
28 36
 }