github.com/kekek/gb@v0.4.5-0.20170222120241-d4ba64b0b297/project.go (about) 1 package gb 2 3 import ( 4 "path/filepath" 5 ) 6 7 // Project represents a gb project. A gb project has a simlar layout to 8 // a $GOPATH workspace. Each gb project has a standard directory layout 9 // starting at the project root, which we'll refer too as $PROJECT. 10 // 11 // $PROJECT/ - the project root 12 // $PROJECT/src/ - base directory for the source of packages 13 // $PROJECT/bin/ - base directory for the compiled binaries 14 type Project interface { 15 16 // Projectdir returns the path root of this project. 17 Projectdir() string 18 19 // Pkgdir returns the path to precompiled packages. 20 Pkgdir() string 21 22 // Bindir returns the path for compiled programs. 23 bindir() string 24 } 25 26 type project struct { 27 rootdir string 28 } 29 30 func NewProject(root string) Project { 31 proj := project{ 32 rootdir: root, 33 } 34 return &proj 35 } 36 37 // Pkgdir returns the path to precompiled packages. 38 func (p *project) Pkgdir() string { 39 return filepath.Join(p.rootdir, "pkg") 40 } 41 42 // Projectdir returns the path root of this project. 43 func (p *project) Projectdir() string { 44 return p.rootdir 45 } 46 47 // Bindir returns the path for compiled programs. 48 func (p *project) bindir() string { 49 return filepath.Join(p.rootdir, "bin") 50 }