blob: 20cddb704bf231f9630aa5e519e5b5fd2dd90126 [file] [log] [blame]
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
// The run program is invoked via the dist tool.
// To invoke manually: go tool dist test -run api --no-rebuild
package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
)
var goroot string
func main() {
log.SetFlags(0)
goroot = os.Getenv("GOROOT") // should be set by run.{bash,bat}
if goroot == "" {
log.Fatal("No $GOROOT set.")
}
out, err := exec.Command("go", "tool", "api",
"-c", file("go1", "go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8", "go1.9"),
"-next", file("next"),
"-except", file("except")).CombinedOutput()
if err != nil {
log.Fatalf("Error running API checker: %v\n%s", err, out)
}
fmt.Print(string(out))
}
// file expands s to $GOROOT/api/s.txt.
// If there are more than 1, they're comma-separated.
func file(s ...string) string {
if len(s) > 1 {
return file(s[0]) + "," + file(s[1:]...)
}
return filepath.Join(goroot, "api", s[0]+".txt")
}