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