1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build ignore 6 7 // The run program is invoked via the dist tool. 8 // To invoke manually: go tool dist test -run api --no-rebuild 9 package main 10 11 import ( 12 "fmt" 13 "log" 14 "os" 15 "os/exec" 16 "path/filepath" 17 ) 18 19 var goroot string 20 21 func main() { 22 log.SetFlags(0) 23 goroot = os.Getenv("GOROOT") // should be set by run.{bash,bat} 24 if goroot == "" { 25 log.Fatal("No $GOROOT set.") 26 } 27 28 out, err := exec.Command("go", "tool", "api", 29 "-c", file("go1", "go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8"), 30 "-next", file("next"), 31 "-except", file("except")).CombinedOutput() 32 if err != nil { 33 log.Fatalf("Error running API checker: %v\n%s", err, out) 34 } 35 fmt.Print(string(out)) 36 } 37 38 // file expands s to $GOROOT/api/s.txt. 39 // If there are more than 1, they're comma-separated. 40 func file(s ...string) string { 41 if len(s) > 1 { 42 return file(s[0]) + "," + file(s[1:]...) 43 } 44 return filepath.Join(goroot, "api", s[0]+".txt") 45 } 46