Source File
import.go
Belonging Package
golang.org/x/tools/internal/stdlib
// Copyright 2025 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.
package stdlib
// This file provides the API for the import graph of the standard library.
//
// Be aware that the compiler-generated code for every package
// implicitly depends on package "runtime" and a handful of others
// (see runtimePkgs in GOROOT/src/cmd/internal/objabi/pkgspecial.go).
import (
)
// Imports returns the sequence of packages directly imported by the
// named standard packages, in name order.
// The imports of an unknown package are the empty set.
//
// The graph is built into the application and may differ from the
// graph in the Go source tree being analyzed by the application.
func ( ...string) iter.Seq[string] {
return func( func(string) bool) {
for , := range {
if , := find(); {
var uint64
for := []byte(deps[].deps); len() > 0; {
, := binary.Uvarint()
+=
if !(deps[].name) {
return
}
= [:]
}
}
}
}
}
// Dependencies returns the set of all dependencies of the named
// standard packages, including the initial package,
// in a deterministic topological order.
// The dependencies of an unknown package are the empty set.
//
// The graph is built into the application and may differ from the
// graph in the Go source tree being analyzed by the application.
func ( ...string) iter.Seq[string] {
return func( func(string) bool) {
for , := range {
if , := find(); {
var [1 + len(deps)/8]byte // bit set of seen packages
var func( int) bool
= func( int) bool {
:= byte(1) << ( % 8)
if [/8]& == 0 {
[/8] |=
var uint64
for := []byte(deps[].deps); len() > 0; {
, := binary.Uvarint()
+=
if !(int()) {
return false
}
= [:]
}
if !(deps[].name) {
return false
}
}
return true
}
if !() {
return
}
}
}
}
}
// find returns the index of pkg in the deps table.
func ( string) (int, bool) {
return slices.BinarySearchFunc(deps[:], , func( pkginfo, string) int {
return strings.Compare(.name, )
})
}
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)