@@ -10,7 +10,6 @@ import (
10
10
"bufio"
11
11
"bytes"
12
12
"encoding/json"
13
- "flag"
14
13
"fmt"
15
14
"go/ast"
16
15
"go/build"
@@ -46,8 +45,7 @@ func goCmd() string {
46
45
return "go"
47
46
}
48
47
49
- // contexts are the default contexts which are scanned, unless
50
- // overridden by the -contexts flag.
48
+ // contexts are the default contexts which are scanned.
51
49
var contexts = []* build.Context {
52
50
{GOOS : "linux" , GOARCH : "386" , CgoEnabled : true },
53
51
{GOOS : "linux" , GOARCH : "386" },
@@ -96,25 +94,6 @@ func contextName(c *build.Context) string {
96
94
return s
97
95
}
98
96
99
- func parseContext (c string ) * build.Context {
100
- parts := strings .Split (c , "-" )
101
- if len (parts ) < 2 {
102
- log .Fatalf ("bad context: %q" , c )
103
- }
104
- bc := & build.Context {
105
- GOOS : parts [0 ],
106
- GOARCH : parts [1 ],
107
- }
108
- if len (parts ) == 3 {
109
- if parts [2 ] == "cgo" {
110
- bc .CgoEnabled = true
111
- } else {
112
- log .Fatalf ("bad context: %q" , c )
113
- }
114
- }
115
- return bc
116
- }
117
-
118
97
var internalPkg = regexp .MustCompile (`(^|/)internal($|/)` )
119
98
120
99
var exitCode = 0
@@ -152,12 +131,7 @@ func Check(t *testing.T) {
152
131
153
132
var featureCtx = make (map [string ]map [string ]bool ) // feature -> context name -> true
154
133
for _ , w := range walkers {
155
- pkgNames := w .stdPackages
156
- if flag .NArg () > 0 {
157
- pkgNames = flag .Args ()
158
- }
159
-
160
- for _ , name := range pkgNames {
134
+ for _ , name := range w .stdPackages {
161
135
pkg , err := w .import_ (name )
162
136
if _ , nogo := err .(* build.NoGoError ); nogo {
163
137
continue
@@ -193,7 +167,7 @@ func Check(t *testing.T) {
193
167
bw := bufio .NewWriter (os .Stdout )
194
168
defer bw .Flush ()
195
169
196
- var required , optional []string
170
+ var required []string
197
171
for _ , file := range checkFiles {
198
172
required = append (required , fileFeatures (file , needApproval (file ))... )
199
173
}
@@ -205,7 +179,7 @@ func Check(t *testing.T) {
205
179
if exitCode == 1 {
206
180
t .Errorf ("API database problems found" )
207
181
}
208
- if ! compareAPI (bw , features , required , optional , exception , false ) {
182
+ if ! compareAPI (bw , features , required , exception ) {
209
183
t .Errorf ("API differences found" )
210
184
}
211
185
}
@@ -251,12 +225,11 @@ func portRemoved(feature string) bool {
251
225
strings .Contains (feature , "(darwin-386-cgo)" )
252
226
}
253
227
254
- func compareAPI (w io.Writer , features , required , optional , exception []string , allowAdd bool ) (ok bool ) {
228
+ func compareAPI (w io.Writer , features , required , exception []string ) (ok bool ) {
255
229
ok = true
256
230
257
- optionalSet := set (optional )
258
- exceptionSet := set (exception )
259
231
featureSet := set (features )
232
+ exceptionSet := set (exception )
260
233
261
234
sort .Strings (features )
262
235
sort .Strings (required )
@@ -267,7 +240,7 @@ func compareAPI(w io.Writer, features, required, optional, exception []string, a
267
240
return s
268
241
}
269
242
270
- for len (required ) > 0 || len (features ) > 0 {
243
+ for len (features ) > 0 || len (required ) > 0 {
271
244
switch {
272
245
case len (features ) == 0 || (len (required ) > 0 && required [0 ] < features [0 ]):
273
246
feature := take (& required )
@@ -288,33 +261,15 @@ func compareAPI(w io.Writer, features, required, optional, exception []string, a
288
261
}
289
262
case len (required ) == 0 || (len (features ) > 0 && required [0 ] > features [0 ]):
290
263
newFeature := take (& features )
291
- if optionalSet [newFeature ] {
292
- // Known added feature to the upcoming release.
293
- // Delete it from the map so we can detect any upcoming features
294
- // which were never seen. (so we can clean up the nextFile)
295
- delete (optionalSet , newFeature )
296
- } else {
297
- fmt .Fprintf (w , "+%s\n " , newFeature )
298
- if ! allowAdd {
299
- ok = false // we're in lock-down mode for next release
300
- }
301
- }
264
+ fmt .Fprintf (w , "+%s\n " , newFeature )
265
+ ok = false // feature not in api/next/*
302
266
default :
303
267
take (& required )
304
268
take (& features )
305
269
}
306
270
}
307
271
308
- // In next file, but not in API.
309
- var missing []string
310
- for feature := range optionalSet {
311
- missing = append (missing , feature )
312
- }
313
- sort .Strings (missing )
314
- for _ , feature := range missing {
315
- fmt .Fprintf (w , "±%s\n " , feature )
316
- }
317
- return
272
+ return ok
318
273
}
319
274
320
275
// aliasReplacer applies type aliases to earlier API files,
0 commit comments