github.com/ashleymcnamara/buffalo@v0.8.0/render/resolvers/gopath.go (about) 1 package resolvers 2 3 import ( 4 "os" 5 "path/filepath" 6 ) 7 8 // GoPathResolver will search your entire $GOPATH to find the file 9 // in question. I wouldn't really recommend using this approach. It's 10 // very very slow the first you try to find a file, and there is no 11 // guarantees of finding the right now. 12 type GoPathResolver struct { 13 Path string 14 *RecursiveResolver 15 } 16 17 // Read will search your entire $GOPATH to find the file 18 // in question. I wouldn't really recommend using this approach. It's 19 // very very slow the first you try to find a file, and there is no 20 // guarantees of finding the right now. 21 func (g *GoPathResolver) Read(name string) ([]byte, error) { 22 if g.RecursiveResolver == nil { 23 g.RecursiveResolver = &RecursiveResolver{ 24 Path: filepath.Join(os.Getenv("GOPATH"), "src", g.Path), 25 } 26 } 27 return g.RecursiveResolver.Read(name) 28 } 29 30 // Resolve will search your entire $GOPATH to find the file 31 // in question. I wouldn't really recommend using this approach. It's 32 // very very slow the first you try to find a file, and there is no 33 // guarantees of finding the right now. 34 func (g *GoPathResolver) Resolve(name string) (string, error) { 35 if g.RecursiveResolver == nil { 36 g.RecursiveResolver = &RecursiveResolver{ 37 Path: filepath.Join(os.Getenv("GOPATH"), "src", g.Path), 38 } 39 } 40 return g.RecursiveResolver.Resolve(name) 41 }