Documentation
¶
Overview ¶
Package goschema reads a Go library's source to learn the output schema of each registered resource, data source, and action. The dev CLI feeds the result into the reference checker so trailing field names in references like `resource.app.id` can be validated at compile time.
Index ¶
- func Read(dir string, extra ...ModuleRoot) (*runtime.LibrarySchema, []string, error)
- func ReadLibraryConfiguration(dir string, extra ...ModuleRoot) (*runtime.LibrarySchema, []string, error)
- type Analysis
- type GoLocation
- type ModuleRoot
- type SourceIndex
- type SourceIndexCache
- func (c *SourceIndexCache) Invalidate(dir string)
- func (c *SourceIndexCache) Read(dir string) (schema *runtime.LibrarySchema, index *SourceIndex, warnings []string, ...)
- func (c *SourceIndexCache) ReadLibraryConfiguration(dir string) (schema *runtime.LibrarySchema, index *SourceIndex, warnings []string, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Read ¶
func Read(dir string, extra ...ModuleRoot) (*runtime.LibrarySchema, []string, error)
Read parses the Go library rooted at dir and returns its schema plus any warnings: registered types whose sibling Output struct could not be located, and constraints whose pieces could not be extracted from source. Returns an error when no `Library()` function is found in dir's root package, or when the directory cannot be read. extra lists further module roots the walker may read source from when a referenced type lives outside the library's own module.
func ReadLibraryConfiguration ¶ added in v0.10.0
func ReadLibraryConfiguration( dir string, extra ...ModuleRoot, ) (*runtime.LibrarySchema, []string, error)
ReadLibraryConfiguration parses a package's LibraryConfiguration entry point.
Types ¶
type Analysis ¶ added in v0.8.0
type Analysis struct {
Schema *runtime.LibrarySchema
Index *SourceIndex
Warnings []string
}
Analysis is the complete Go library source analysis.
type GoLocation ¶ added in v0.8.0
GoLocation points at a byte in a Go source file.
type ModuleRoot ¶ added in v0.7.0
ModuleRoot names a module's source on disk: Path is the module's import path and Dir is the directory holding its source. The walker resolves a selector into any root whose Path contains the selector's import path.
type SourceIndex ¶ added in v0.8.0
type SourceIndex struct {
LibraryFunc GoLocation
Registrations map[string]map[string]GoLocation
InputTypes map[string]map[string]GoLocation
OutputTypes map[string]map[string]GoLocation
InputFields map[string]map[string]map[string]GoLocation
OutputFields map[string]map[string]map[string]GoLocation
ConfigType GoLocation
ConfigFields map[string]GoLocation
Functions map[string]GoLocation
}
SourceIndex records source locations for a Go library schema.
func ReadLibraryConfigurationWithIndex ¶ added in v0.10.0
func ReadLibraryConfigurationWithIndex(dir string, extra ...ModuleRoot) ( schema *runtime.LibrarySchema, index *SourceIndex, warnings []string, err error, )
ReadLibraryConfigurationWithIndex reads a config-schema package and source index.
func ReadWithIndex ¶ added in v0.8.0
func ReadWithIndex(dir string, extra ...ModuleRoot) ( schema *runtime.LibrarySchema, index *SourceIndex, warnings []string, err error, )
ReadWithIndex reads a Go library schema and the matching source index.
type SourceIndexCache ¶ added in v0.8.0
type SourceIndexCache struct {
// contains filtered or unexported fields
}
SourceIndexCache caches schema and source-index reads by directory.
func NewSourceIndexCache ¶ added in v0.8.0
func NewSourceIndexCache(extra ...ModuleRoot) *SourceIndexCache
NewSourceIndexCache returns an empty source index cache.
func (*SourceIndexCache) Invalidate ¶ added in v0.8.0
func (c *SourceIndexCache) Invalidate(dir string)
Invalidate removes one directory from the cache.
func (*SourceIndexCache) Read ¶ added in v0.8.0
func (c *SourceIndexCache) Read(dir string) ( schema *runtime.LibrarySchema, index *SourceIndex, warnings []string, err error, )
Read reads a schema and source index, using the cache when present.
func (*SourceIndexCache) ReadLibraryConfiguration ¶ added in v0.10.0
func (c *SourceIndexCache) ReadLibraryConfiguration(dir string) ( schema *runtime.LibrarySchema, index *SourceIndex, warnings []string, err error, )
ReadLibraryConfiguration reads a config-schema package and source index.