2016-03-01 15:57:46 -07:00
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
2013-08-07 14:49:37 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2013-08-09 16:44:00 -06:00
|
|
|
// +build ignore
|
|
|
|
|
2015-04-07 12:04:01 -06:00
|
|
|
// The run program is invoked via the dist tool.
|
|
|
|
// To invoke manually: go tool dist test -run api --no-rebuild
|
2013-08-07 14:49:37 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"path/filepath"
|
2017-09-19 03:18:09 -06:00
|
|
|
"runtime"
|
2013-08-07 14:49:37 -06:00
|
|
|
)
|
|
|
|
|
2017-09-19 03:18:09 -06:00
|
|
|
func goCmd() string {
|
|
|
|
var exeSuffix string
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
exeSuffix = ".exe"
|
|
|
|
}
|
|
|
|
path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
|
|
|
|
if _, err := os.Stat(path); err == nil {
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
return "go"
|
|
|
|
}
|
|
|
|
|
2013-08-07 14:49:37 -06:00
|
|
|
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.")
|
|
|
|
}
|
2013-08-08 12:06:38 -06:00
|
|
|
|
2017-09-19 03:18:09 -06:00
|
|
|
out, err := exec.Command(goCmd(), "tool", "api",
|
2017-12-06 14:47:52 -07:00
|
|
|
"-c", file("go1", "go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8", "go1.9", "go1.10"),
|
2013-08-07 14:49:37 -06:00
|
|
|
"-next", file("next"),
|
|
|
|
"-except", file("except")).CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error running API checker: %v\n%s", err, out)
|
|
|
|
}
|
2013-08-08 14:36:22 -06:00
|
|
|
fmt.Print(string(out))
|
2013-08-07 14:49:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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")
|
|
|
|
}
|