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 ¶
- Variables
- func EarliestClosedSchemaVersion() string
- func Format(f *File) ([]byte, error)
- type Dep
- type File
- func FixLegacy(modfile []byte, filename string) (*File, error)
- func Parse(modfile []byte, filename string) (*File, error)
- func ParseLegacy(modfile []byte, filename string) (*File, error)
- func ParseNonStrict(modfile []byte, filename string) (*File, error)
- type Language
- type Source
Variables ¶
ErrNoLanguageVersion is returned by Parse and ParseNonStrict when a cue.mod/module.cue file lacks the `language.version` field.
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 Format ¶
Format returns a formatted representation of f in CUE syntax.
Types ¶
type Dep ¶
type Dep = modfiledata.Dep
type File ¶
type File = modfiledata.File
File represents the contents of a cue.mod/module.cue file.
func FixLegacy ¶
FixLegacy converts a legacy module.cue file as parsed by ParseLegacy into a format suitable for parsing with Parse. It adds a language.version field and moves all unrecognized fields into custom.legacy.
If there is no module field or it is empty, it is set to "test.example".
If the file already parses OK with ParseNonStrict, it returns the result of that.
func Parse ¶
Parse verifies that the module file has correct syntax and follows the schema following the required language.version field. 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.
type Language ¶
type Language = modfiledata.Language
type Source ¶
type Source = modfiledata.Source
Source represents how to transform from a module's source to its actual contents.
Source Files ¶
modfile.go
- Version
- v0.15.1 (latest)
- Published
- Nov 21, 2025
- Platform
- linux/amd64
- Imports
- 16 packages
- Last checked
- 4 months ago –
Tools for package owners.