Documentation
¶
Overview ¶
Package publicapi reports every exported identifier of a public package that refers to a type from an internal/ package: a program outside the module can read such a type but cannot name or build it, and the internal package becomes part of the public contract. The public package gives itself its own type instead and converts at its edge.
An import is internal when a path element of it is "internal". An import alone is never reported, and neither is one used only inside function bodies; a dot import of an internal package is, since its names read as the package's own. Read are the exported API's types: an exported type's exported fields, embedded types, interface methods, what it is declared as or aliased to, and its type parameters' constraints; the parameters, results and constraints of exported functions and of exported methods on exported types; and the declared types of exported variables and constants. An exported variable or constant with no declared type whose value names an internal package is reported too, since syntax alone cannot tell what the value's type is. A type declared unexported in the same package that the API reaches is followed to its exported fields, embedded types and exported methods, which the API shows through it.
Like the other rules of codecheck it reads syntax alone, with no type checking, so it is a check, not a proof.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Finding ¶
type Finding struct {
Dir string // package directory, relative to the module, slash-separated
Message string
}
Finding is one exported identifier, or one dot import, that shows an internal type.
func Check ¶
Check reports, sorted by file and line, each exported identifier of the package in dir that refers to a type from an internal package, one finding per identifier and internal type, and each dot import of an internal package. root is the module's directory, module its path, dir the package's directory relative to root and files its Go files; test files are skipped. A file that does not parse is an error.