gocuelang.org/go/internal/mod/modimports Index | Files

package modimports

import "cuelang.org/go/internal/mod/modimports"

Index

Functions

func AllImports

func AllImports(modFilesIter iter.Seq2[ModuleFile, error]) ([]string, error)

AllImports returns a sorted list of all the package paths imported by the module files produced by modFilesIter in canonical form.

If the modFilesIter yields an err then AllImports immediately stops and returns the accumulated package paths.

func AllModuleFiles

func AllModuleFiles(fsys fs.FS, root string) iter.Seq2[ModuleFile, error]

AllModuleFiles returns an iterator that produces all the CUE files inside the module at the given root.

The caller may assume that files from the same package are always adjacent.

func PackageFiles

func PackageFiles(fsys fs.FS, dir string, pkgQualifier string) iter.Seq2[ModuleFile, error]

PackageFiles returns an iterator that produces all the CUE files inside the package with the given name at the given location. If pkgQualifier is "*", files from all packages in the directory will be produced.

The iterator will yield an error if an I/O error is encountered when accessing the fsys.

TODO(mvdan): this should now be called InstanceFiles, to follow the naming from https://cuelang.org/docs/concept/modules-packages-instances/#instances.

Types

type ModuleFile

type ModuleFile struct {
	// FilePath holds the path of the module file
	// relative to the root of the fs. This will be
	// valid even if there's an associated error.
	//
	// If there's an error, it might not a be CUE file.
	FilePath string

	// Syntax (and SyntaxError) are the results from invoking
	// [parser.ParseFile]
	Syntax      *ast.File
	SyntaxError error
}

Source Files

modimports.go

Version
v0.15.1 (latest)
Published
Nov 21, 2025
Platform
linux/amd64
Imports
13 packages
Last checked
4 months ago

Tools for package owners.