github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/scripts/make-vendor.go (about) 1 /* 2 The current vendoring solution supports both new and old style 3 vendoring, via a trick: We commit all vendored code to the "vendor" 4 directory, and then, if we're on a version/deployment of go that 5 doesn't support new style vendoring, we symlink to "build/vendor/src" 6 and add "build/vendor" to the gopath, which the render-gopath program 7 generates inside of the makefile. 8 9 This script sets up the symlink. This is somewhat fragile for go1.5 10 and go1.6, if you change the value of the GO15VENDOREXPERIMENT 11 environment variable, in between runs of "make-vendor" and 12 builds. Similar switching between go1.4 environments and go1.6 13 will require manually rerunning this script. 14 */ 15 package main 16 17 import ( 18 "fmt" 19 "os" 20 "path/filepath" 21 22 "./vendoring" 23 ) 24 25 func main() { 26 if vendoring.NeedsLegacy() { 27 pwd, err := os.Getwd() 28 if err != nil { 29 fmt.Println(err.Error()) 30 os.Exit(1) 31 } 32 33 path := filepath.Join(pwd, vendoring.Path) 34 35 if _, err = os.Stat(path); !os.IsNotExist(err) { 36 fmt.Println("legacy vendor path configured.") 37 return 38 } 39 40 err = os.MkdirAll(path, 0755) 41 if err != nil { 42 fmt.Println(err.Error()) 43 os.Exit(1) 44 45 } 46 47 err = os.Symlink(filepath.Join(pwd, "vendor"), filepath.Join(pwd, vendoring.Src)) 48 if err != nil { 49 fmt.Println(err.Error()) 50 os.Exit(1) 51 } 52 53 fmt.Println("created vendor legacy link") 54 return 55 } 56 57 fmt.Println("can use existing (new-style) vendoring configuration") 58 }