github.com/aca02djr/gb@v0.4.1/example_test.go (about) 1 package gb_test 2 3 import ( 4 "log" 5 "path/filepath" 6 7 "github.com/constabulary/gb" 8 ) 9 10 func ExampleNewProject() { 11 12 // Every project begins with a project root. 13 // Normally you'd check this out of source control. 14 root := filepath.Join("home", "dfc", "devel", "demo") 15 16 // Create a new Project passing in the source directories 17 // under this project's root. 18 proj := gb.NewProject(root, 19 gb.SourceDir(filepath.Join(root, "src")), // $PROJECT/src 20 gb.SourceDir(filepath.Join(root, "vendor", "src")), // $PROJECT/vendor/src 21 ) 22 23 // Create a new Context from the Project. A Context holds 24 // the state of a specific compilation or test within the Project. 25 ctx, err := proj.NewContext() 26 if err != nil { 27 log.Fatal("Could not create new context:", err) 28 } 29 30 // Always remember to clean up your Context 31 ctx.Destroy() 32 }