github.com/gsquire/gb@v0.4.4-0.20161112235727-3982dc872064/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 20 // Create a new Context from the Project. A Context holds 21 // the state of a specific compilation or test within the Project. 22 ctx, err := gb.NewContext(proj) 23 if err != nil { 24 log.Fatal("Could not create new context:", err) 25 } 26 27 // Always remember to clean up your Context 28 ctx.Destroy() 29 }