package modfile
import "cuelang.org/go/mod/modfile"
Package modfile provides functionality for reading and parsing the CUE module file, cue.mod/module.cue.
WARNING: THIS PACKAGE IS EXPERIMENTAL. ITS API MAY CHANGE AT ANY TIME.
Index ¶
- func EarliestClosedSchemaVersion() string
- func LatestKnownSchemaVersion() string
- type Dep
- type File
- func Parse(modfile []byte, filename string) (*File, error)
- func ParseLegacy(modfile []byte, filename string) (*File, error)
- func ParseNonStrict(modfile []byte, filename string) (*File, error)
- func (f *File) DefaultMajorVersions() map[string]string
- func (f *File) DepVersions() []module.Version
- func (f *File) Format() ([]byte, error)
- type Language
- type Source
Functions ¶
func EarliestClosedSchemaVersion ¶
func EarliestClosedSchemaVersion() string
EarliestClosedSchemaVersion returns the earliest module.cue schema version that excludes unknown fields. Any version declared in a module.cue file should be at least this, because that's when we added the language.version field itself.
func LatestKnownSchemaVersion ¶
func LatestKnownSchemaVersion() string
LatestKnownSchemaVersion returns the language version associated with the most recent known schema.
Types ¶
type Dep ¶
type File ¶
type File struct { Module string `json:"module"` Language *Language `json:"language,omitempty"` Source *Source `json:"source,omitempty"` Deps map[string]*Dep `json:"deps,omitempty"` // contains filtered or unexported fields }
File represents the contents of a cue.mod/module.cue file.
func Parse ¶
Parse verifies that the module file has correct syntax. The file name is used for error messages. All dependencies must be specified correctly: with major versions in the module paths and canonical dependency versions.
func ParseLegacy ¶
ParseLegacy parses the legacy version of the module file that only supports the single field "module" and ignores all other fields.
func ParseNonStrict ¶
ParseNonStrict is like Parse but allows some laxity in the parsing:
- if a module path lacks a version, it's taken from the version.
- if a non-canonical version is used, it will be canonicalized.
The file name is used for error messages.
func (*File) DefaultMajorVersions ¶
DefaultMajorVersions returns a map from module base path to the major version that's specified as the default for that module. The caller should not modify the returned map.
func (*File) DepVersions ¶
DepVersions returns the versions of all the modules depended on by the file. The caller should not modify the returned slice.
This always returns the same value, even if the contents of f are changed. If f was not created with Parse, it returns nil.
func (*File) Format ¶
Format returns a formatted representation of f in CUE syntax.
type Language ¶
type Language struct { Version string `json:"version,omitempty"` }
type Source ¶
type Source struct { Kind string `json:"kind"` }
Source represents how to transform from a module's source to its actual contents.
func (*Source) Validate ¶
Validate checks that src is well formed.
Source Files ¶
modfile.go
- Version
- v0.9.0-alpha.4
- Published
- May 1, 2024
- Platform
- windows/amd64
- Imports
- 15 packages
- Last checked
- 42 minutes ago –
Tools for package owners.