Commit 75c8a78e authored by Russ Cox's avatar Russ Cox

[release-branch.go1.4] cmd/api: make API check fail for undeclared API in release branch

We forgot to do the usual API review.
Make that not possible in the future.
I'll pull this change over to the main
branch too, but it's more important
(and only testable) here.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/185050043
parent f42f5263
...@@ -283,7 +283,7 @@ func compareAPI(w io.Writer, features, required, optional, exception []string) ( ...@@ -283,7 +283,7 @@ func compareAPI(w io.Writer, features, required, optional, exception []string) (
delete(optionalSet, newFeature) delete(optionalSet, newFeature)
} else { } else {
fmt.Fprintf(w, "+%s\n", newFeature) fmt.Fprintf(w, "+%s\n", newFeature)
if !*allowNew { if !*allowNew || !strings.Contains(runtime.Version(), "devel") {
ok = false // we're in lock-down mode for next release ok = false // we're in lock-down mode for next release
} }
} }
...@@ -313,11 +313,15 @@ func fileFeatures(filename string) []string { ...@@ -313,11 +313,15 @@ func fileFeatures(filename string) []string {
if err != nil { if err != nil {
log.Fatalf("Error reading file %s: %v", filename, err) log.Fatalf("Error reading file %s: %v", filename, err)
} }
text := strings.TrimSpace(string(bs)) lines := strings.Split(string(bs), "\n")
if text == "" { var nonblank []string
return nil for _, line := range lines {
line = strings.TrimSpace(line)
if line != "" && !strings.HasPrefix(line, "#") {
nonblank = append(nonblank, line)
}
} }
return strings.Split(text, "\n") return nonblank
} }
var fset = token.NewFileSet() var fset = token.NewFileSet()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment