Documentation ¶
Overview ¶
Package pkgsyms extends the reflect package so that any symbols exported by a package are accessible by name to another package.
Note that the inability to get a type or global function by its name is not an oversight of the reflect package- it's a strength that allows the compiler and runtime to omit functions, and possibly types, that aren't referenced from anywhere during compilation.
In order for the pkgsyms package to work, users of the pkgsyms package must run a go generate command that essentially subverts the compiler's ability to eliminate dead code by making all exported names accessible outside of the package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Pkg = Of("github.com/skillian/pkgsyms")
Functions ¶
This section is empty.
Types ¶
type Const ¶
type Const struct {
// contains filtered or unexported fields
}
Const holds the value of a constant. Unlike Go compile-time constants, because we're actually holding onto values at runtime, these "constants" have actual types.
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
Func is a global function Symbol.
type Package ¶
type Package struct { // Name of the package. Do not mutate this string. Name string // Symbols exported by the package Symbols }
Package defines a package. It includes the package name and its exported symbols.
type Symbol ¶
type Symbol interface { // Name is the exported name of the symbol Name() string // Get the value associated with the symbol. Get() interface{} }
Symbol is an exported constant, function, type or variable.
Symbols have names and values. What you get by calling their Get function depends on the Symbol implementation. Unlike the plugin package which leaves its Symbol definitions directly available to type assertions, you should instead try to type-assert against the result of the Get function.
type Symbols ¶
type Symbols struct {
// contains filtered or unexported fields
}
Symbols are exported names in a package which can include things like constants, functions, types and variables.
func MakeSymbols ¶
MakeSymbols creates a collection of symbols
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type holds a reflect.Type defined in the package.