Documentation
¶
Overview ¶
Package modfiledata holds the underlying module.cue file representation. It is separate from the cuelang.org/go/mod/modfile package to allow the type to be used without incurring the dependency on the CUE evaluator brought in by the [modfile.Parse] and [modfile.Format] functions.
WARNING: THIS PACKAGE IS EXPERIMENTAL. ITS API MAY CHANGE AT ANY TIME.
Index ¶
- type Dep
- type File
- func (f *File) DefaultMajorVersions() map[string]string
- func (f *File) DepVersions() []module.Version
- func (f *File) Init() error
- func (f *File) InitNonStrict() error
- func (f *File) MajorVersion() string
- func (f *File) ModuleForImportPath(importPath string) (module.Version, bool)
- func (f *File) ModulePath() stringdeprecated
- func (f *File) ModuleRootPath() string
- func (f *File) QualifiedModule() string
- type Language
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// Module holds the module path, which may
// not contain a major version suffix.
// Use the [File.QualifiedModule] method to obtain a module
// path that's always qualified. See also the
// [File.ModulePath] and [File.MajorVersion] methods.
Module string `json:"module"`
Language *Language `json:"language,omitempty"`
Source *Source `json:"source,omitempty"`
Deps map[string]*Dep `json:"deps,omitempty"`
Custom map[string]map[string]any `json:"custom,omitempty"`
// contains filtered or unexported fields
}
File represents the contents of a cue.mod/module.cue file. Use cuelang.org/go/mod/modfile.Parse to parse the file in its standard format.
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) Init ¶
Init initializes the private dependency-related fields of f from the public fields.
func (*File) InitNonStrict ¶
InitNonStrict is like File.Init but does not enforce full strictness in dependencies (for example, it allows dependency module paths without major version suffixes).
func (*File) MajorVersion ¶
MajorVersion returns the major version of the module, not including the "@". If there is no module (which can happen when [ParseLegacy] is used or if Module is explicitly set to an empty string), it returns the empty string.
func (*File) ModuleForImportPath ¶
ModuleForImportPath returns the module that should contain the given import path and reports whether the module was found. It does not check to see if the import path actually exists within the module.
It works entirely from information in f, meaning that it does not consult a registry to resolve a package whose module is not mentioned in the file, which means it will not work in general unless the module is tidy (as with `cue mod tidy`).
func (*File) ModulePath
deprecated
Deprecated: this method is misnamed; use File.ModuleRootPath instead.
func (*File) ModuleRootPath ¶
ModuleRootPath returns the path part of the module without its major version suffix.
func (*File) QualifiedModule ¶
QualifiedModule returns the fully qualified module path if there is one. It returns the empty string when [ParseLegacy] has been used and the module field is empty.
Note that when the module field does not contain a major version suffix, "@v0" is assumed.