Documentation
¶
Index ¶
- func SortImports(imports []Import)
- type GroupedImports
- type Import
- type ImportSet
- type RecursiveAppend
- func (r RecursiveAppend[T]) Current() T
- func (r RecursiveAppend[T]) IsLast() bool
- func (r RecursiveAppend[T]) IterVar() string
- func (r RecursiveAppend[T]) Next() (RecursiveAppend[T], error)
- func (r RecursiveAppend[T]) NextIterVar() string
- func (r *RecursiveAppend[T]) SetData(key string, value any) error
- func (r RecursiveAppend[T]) WithRoot(root string) RecursiveAppend[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortImports ¶
func SortImports(imports []Import)
SortImports performs an in-place sort on the passed imports, sorting each by the Path.
Types ¶
type GroupedImports ¶
GroupedImports groups imports into different sections, for cleaner import blocks.
func GroupImports ¶
func GroupImports(imports []Import) GroupedImports
GroupImports groups the passed imports into a GroupedImports. Each group maintains the relative order of the imports.
func (GroupedImports) Groups ¶
func (i GroupedImports) Groups() [][]Import
Groups returns a slice of slice of Import, with each top-level slice being a different group. The groups are ordered as standard library, third party, and then module imports.
func (GroupedImports) Len ¶
func (i GroupedImports) Len() int
Len returns the total number of imports
type ImportSet ¶
type ImportSet map[Import]struct{}
ImportSet is a set of Imports (for removing duplicates). Its zero value can be used without initialization.
type RecursiveAppend ¶
RecursiveAppend is used in templates to give a way to concisely reference nested fields.
func (RecursiveAppend[T]) Current ¶
func (r RecursiveAppend[T]) Current() T
func (RecursiveAppend[T]) IsLast ¶
func (r RecursiveAppend[T]) IsLast() bool
func (RecursiveAppend[T]) IterVar ¶
func (r RecursiveAppend[T]) IterVar() string
func (RecursiveAppend[T]) Next ¶
func (r RecursiveAppend[T]) Next() (RecursiveAppend[T], error)
func (RecursiveAppend[T]) NextIterVar ¶
func (r RecursiveAppend[T]) NextIterVar() string
func (*RecursiveAppend[T]) SetData ¶
func (r *RecursiveAppend[T]) SetData(key string, value any) error
func (RecursiveAppend[T]) WithRoot ¶
func (r RecursiveAppend[T]) WithRoot(root string) RecursiveAppend[T]