Skip to content

Commit 9c55792

Browse files
committed
go/build: update deps list
A while back we discovered that the dependencies test allowed arbitrary dependencies for packages we forgot to list. To stop the damage we added a grandfathered list and fixed the code to expect unlisted packages to have no dependencies. This CL replaces the grandfathered list with some more careful placement of dependency rules. Thankfully, there were no terrible inversions. Fixes #10487. Change-Id: I5a6f92435bd2c66c47ec8ab629edbd88b189f028 Reviewed-on: https://go-review.googlesource.com/12575 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
1 parent f6fb549 commit 9c55792

File tree

1 file changed

+72
-74
lines changed

1 file changed

+72
-74
lines changed

src/go/build/deps_test.go

Lines changed: 72 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,12 @@ var pkgDeps = map[string][]string{
124124
// End of linear dependency definitions.
125125

126126
// Operating system access.
127-
"syscall": {"L0", "unicode/utf16"},
127+
"syscall": {"L0", "unicode/utf16"},
128+
"internal/syscall/unix": {"L0", "syscall"},
129+
"internal/syscall/windows": {"L0", "syscall"},
130+
"internal/syscall/windows/registry": {"L0", "syscall", "unicode/utf16"},
128131
"time": {"L0", "syscall", "internal/syscall/windows/registry"},
129-
"os": {"L1", "os", "syscall", "time", "internal/syscall/windows", "C"},
132+
"os": {"L1", "os", "syscall", "time", "internal/syscall/windows"},
130133
"path/filepath": {"L2", "os", "syscall"},
131134
"io/ioutil": {"L2", "os", "path/filepath", "time"},
132135
"os/exec": {"L2", "os", "path/filepath", "syscall"},
@@ -154,9 +157,10 @@ var pkgDeps = map[string][]string{
154157
"runtime/trace": {"L0"},
155158
"text/tabwriter": {"L2"},
156159

157-
"testing": {"L2", "flag", "fmt", "os", "runtime/pprof", "runtime/trace", "time"},
158-
"testing/iotest": {"L2", "log"},
159-
"testing/quick": {"L2", "flag", "fmt", "reflect"},
160+
"testing": {"L2", "flag", "fmt", "os", "runtime/pprof", "runtime/trace", "time"},
161+
"testing/iotest": {"L2", "log"},
162+
"testing/quick": {"L2", "flag", "fmt", "reflect"},
163+
"internal/testenv": {"L2", "testing"},
160164

161165
// L4 is defined as L3+fmt+log+time, because in general once
162166
// you're using L3 packages, use of fmt, log, or time is not a big deal.
@@ -184,44 +188,60 @@ var pkgDeps = map[string][]string{
184188
"go/token",
185189
},
186190

191+
"go/format": {"L4", "GOPARSER", "internal/format"},
192+
"internal/format": {"L4", "GOPARSER"},
193+
194+
// Go type checking.
195+
"go/constant": {"L4", "go/token", "math/big"},
196+
"go/importer": {"L4", "go/internal/gcimporter", "go/internal/gccgoimporter", "go/types"},
197+
"go/internal/gcimporter": {"L4", "OS", "go/build", "go/constant", "go/token", "go/types", "text/scanner"},
198+
"go/internal/gccgoimporter": {"L4", "OS", "debug/elf", "go/constant", "go/token", "go/types", "text/scanner"},
199+
"go/types": {"L4", "GOPARSER", "container/heap", "go/constant"},
200+
187201
// One of a kind.
188-
"archive/tar": {"L4", "OS", "syscall"},
189-
"archive/zip": {"L4", "OS", "compress/flate"},
190-
"compress/bzip2": {"L4"},
191-
"compress/flate": {"L4"},
192-
"compress/gzip": {"L4", "compress/flate"},
193-
"compress/lzw": {"L4"},
194-
"compress/zlib": {"L4", "compress/flate"},
195-
"database/sql": {"L4", "container/list", "database/sql/driver"},
196-
"database/sql/driver": {"L4", "time"},
197-
"debug/dwarf": {"L4"},
198-
"debug/elf": {"L4", "OS", "debug/dwarf"},
199-
"debug/gosym": {"L4"},
200-
"debug/macho": {"L4", "OS", "debug/dwarf"},
201-
"debug/pe": {"L4", "OS", "debug/dwarf"},
202-
"encoding": {"L4"},
203-
"encoding/ascii85": {"L4"},
204-
"encoding/asn1": {"L4", "math/big"},
205-
"encoding/csv": {"L4"},
206-
"encoding/gob": {"L4", "OS", "encoding"},
207-
"encoding/hex": {"L4"},
208-
"encoding/json": {"L4", "encoding"},
209-
"encoding/pem": {"L4"},
210-
"encoding/xml": {"L4", "encoding"},
211-
"flag": {"L4", "OS"},
212-
"go/build": {"L4", "OS", "GOPARSER"},
213-
"html": {"L4"},
214-
"image/draw": {"L4", "image/internal/imageutil"},
215-
"image/gif": {"L4", "compress/lzw", "image/color/palette", "image/draw"},
216-
"image/jpeg": {"L4", "image/internal/imageutil"},
217-
"image/png": {"L4", "compress/zlib"},
218-
"index/suffixarray": {"L4", "regexp"},
219-
"math/big": {"L4"},
220-
"mime": {"L4", "OS", "syscall", "internal/syscall/windows/registry"},
221-
"mime/quotedprintable": {"L4"},
222-
"net/url": {"L4"},
223-
"text/scanner": {"L4", "OS"},
224-
"text/template/parse": {"L4"},
202+
"archive/tar": {"L4", "OS", "syscall"},
203+
"archive/zip": {"L4", "OS", "compress/flate"},
204+
"container/heap": {"sort"},
205+
"compress/bzip2": {"L4"},
206+
"compress/flate": {"L4"},
207+
"compress/gzip": {"L4", "compress/flate"},
208+
"compress/lzw": {"L4"},
209+
"compress/zlib": {"L4", "compress/flate"},
210+
"database/sql": {"L4", "container/list", "database/sql/driver"},
211+
"database/sql/driver": {"L4", "time"},
212+
"debug/dwarf": {"L4"},
213+
"debug/elf": {"L4", "OS", "debug/dwarf"},
214+
"debug/gosym": {"L4"},
215+
"debug/macho": {"L4", "OS", "debug/dwarf"},
216+
"debug/pe": {"L4", "OS", "debug/dwarf"},
217+
"debug/plan9obj": {"L4", "OS"},
218+
"encoding": {"L4"},
219+
"encoding/ascii85": {"L4"},
220+
"encoding/asn1": {"L4", "math/big"},
221+
"encoding/csv": {"L4"},
222+
"encoding/gob": {"L4", "OS", "encoding"},
223+
"encoding/hex": {"L4"},
224+
"encoding/json": {"L4", "encoding"},
225+
"encoding/pem": {"L4"},
226+
"encoding/xml": {"L4", "encoding"},
227+
"flag": {"L4", "OS"},
228+
"go/build": {"L4", "OS", "GOPARSER"},
229+
"html": {"L4"},
230+
"image/draw": {"L4", "image/internal/imageutil"},
231+
"image/gif": {"L4", "compress/lzw", "image/color/palette", "image/draw"},
232+
"image/internal/imageutil": {"L4"},
233+
"image/jpeg": {"L4", "image/internal/imageutil"},
234+
"image/png": {"L4", "compress/zlib"},
235+
"index/suffixarray": {"L4", "regexp"},
236+
"internal/singleflight": {"sync"},
237+
"internal/trace": {"L4", "OS"},
238+
"math/big": {"L4"},
239+
"mime": {"L4", "OS", "syscall", "internal/syscall/windows/registry"},
240+
"mime/quotedprintable": {"L4"},
241+
"net/internal/socktest": {"L4", "OS", "syscall"},
242+
"net/url": {"L4"},
243+
"text/scanner": {"L4", "OS"},
244+
"text/template/parse": {"L4"},
225245

226246
"html/template": {
227247
"L4", "OS", "encoding/json", "html", "text/template",
@@ -325,40 +345,18 @@ var pkgDeps = map[string][]string{
325345
"compress/gzip", "crypto/tls", "mime/multipart", "runtime/debug",
326346
"net/http/internal",
327347
},
348+
"net/http/internal": {"L4"},
328349

329350
// HTTP-using packages.
330-
"expvar": {"L4", "OS", "encoding/json", "net/http"},
331-
"net/http/cgi": {"L4", "NET", "OS", "crypto/tls", "net/http", "regexp"},
332-
"net/http/fcgi": {"L4", "NET", "OS", "net/http", "net/http/cgi"},
333-
"net/http/httptest": {"L4", "NET", "OS", "crypto/tls", "flag", "net/http"},
334-
"net/http/httputil": {"L4", "NET", "OS", "net/http", "net/http/internal"},
335-
"net/http/pprof": {"L4", "OS", "html/template", "net/http", "runtime/pprof", "runtime/trace"},
336-
"net/rpc": {"L4", "NET", "encoding/gob", "html/template", "net/http"},
337-
"net/rpc/jsonrpc": {"L4", "NET", "encoding/json", "net/rpc"},
338-
339-
// Packages below are grandfathered because of issue 10475.
340-
// When updating these entries, move them to an appropriate
341-
// location above and assign them a justified set of
342-
// dependencies. Do not simply update them in situ.
343-
"container/heap": {"sort"},
344-
"debug/plan9obj": {"encoding/binary", "errors", "fmt", "io", "os"},
345-
"go/constant": {"fmt", "go/token", "math/big", "strconv"},
346-
"go/format": {"bytes", "fmt", "go/ast", "go/parser", "go/printer", "go/token", "internal/format", "io"},
347-
"go/importer": {"go/internal/gcimporter", "go/internal/gccgoimporter", "go/types", "io", "runtime"},
348-
"go/internal/gcimporter": {"bufio", "errors", "fmt", "go/build", "go/constant", "go/token", "go/types", "io", "os", "path/filepath", "sort", "strconv", "strings", "text/scanner"},
349-
"go/internal/gccgoimporter": {"bufio", "bytes", "debug/elf", "errors", "fmt", "go/constant", "go/token", "go/types", "io", "os", "os/exec", "path/filepath", "strconv", "strings", "text/scanner"},
350-
"go/types": {"bytes", "container/heap", "fmt", "go/ast", "go/constant", "go/parser", "go/token", "io", "math", "path", "sort", "strconv", "strings", "sync", "unicode"},
351-
"image/internal/imageutil": {"image"},
352-
"internal/format": {"bytes", "go/ast", "go/parser", "go/printer", "go/token", "strings"},
353-
"internal/singleflight": {"sync"},
354-
"internal/syscall/unix": {"runtime", "sync/atomic", "syscall", "unsafe"},
355-
"internal/syscall/windows": {"syscall", "unsafe"},
356-
"internal/syscall/windows/registry": {"errors", "io", "syscall", "unicode/utf16", "unsafe"},
357-
"internal/testenv": {"runtime", "strings", "testing"},
358-
"internal/trace": {"bufio", "bytes", "fmt", "io", "os", "os/exec", "sort", "strconv", "strings"},
359-
"net/http/cookiejar": {"errors", "fmt", "net", "net/http", "net/url", "sort", "strings", "sync", "time", "unicode/utf8"},
360-
"net/http/internal": {"bufio", "bytes", "errors", "fmt", "io"},
361-
"net/internal/socktest": {"fmt", "sync", "syscall"},
351+
"expvar": {"L4", "OS", "encoding/json", "net/http"},
352+
"net/http/cgi": {"L4", "NET", "OS", "crypto/tls", "net/http", "regexp"},
353+
"net/http/cookiejar": {"L4", "NET", "net/http"},
354+
"net/http/fcgi": {"L4", "NET", "OS", "net/http", "net/http/cgi"},
355+
"net/http/httptest": {"L4", "NET", "OS", "crypto/tls", "flag", "net/http"},
356+
"net/http/httputil": {"L4", "NET", "OS", "net/http", "net/http/internal"},
357+
"net/http/pprof": {"L4", "OS", "html/template", "net/http", "runtime/pprof", "runtime/trace"},
358+
"net/rpc": {"L4", "NET", "encoding/gob", "html/template", "net/http"},
359+
"net/rpc/jsonrpc": {"L4", "NET", "encoding/json", "net/rpc"},
362360
}
363361

364362
// isMacro reports whether p is a package dependency macro

0 commit comments

Comments
 (0)