Documentation ¶
Index ¶
- Constants
- Variables
- func CheckWorkspace()
- func CopyDirRecursively(sourceDir, destDir string) error
- func CopyFile(sourceFile, destFile string)
- func CutPrefix(str string, prefix string) (string, bool)
- func DirExists(dir string) bool
- func EnsureManagedDir(dir string)
- func FileExists(file string) bool
- func GenerateFile(filePath string, tmpl template.Template, args any)
- func GetModuleRoot() string
- func GetModuleRootForPath(p string) string
- func GetWorkingDir() string
- func GetWorkspaceRoot() string
- func MappedSlice[V any, U any](values []V, f func(V) U) []U
- func MkdirAll(p string)
- func OrderedKeys[K constraints.Ordered, V any](m map[K]V) []K
- func OrderedSlice[V constraints.Ordered](values []V) []V
- func OrderedValues[K constraints.Ordered, V any](m map[K]V) []V
- func ReadFile(filePath string) []byte
- func ReadJson(filePath string, v interface{})
- func ReadYaml(filePath string, v interface{})
- func RemoveDir(p string)
- func SliceOrderedBy[V any, K constraints.Ordered](values []V, key func(v *V) K) []V
- func Version() string
- func VersionTriplet() [3]uint
- func WalkSymlink(root string, walkFn filepath.WalkFunc) error
- func WriteFile(filePath string, data []byte)
- func WriteJson(filePath string, v interface{})
- func WriteYaml(filePath string, v interface{})
- type OrderedMap
- func (m *OrderedMap[K, V]) AllowOverrides()
- func (m *OrderedMap[K, V]) Entries() []OrderedMapEntry[K, V]
- func (m *OrderedMap[K, V]) Get(key K) V
- func (m *OrderedMap[K, V]) Insert(key K, value V)
- func (m *OrderedMap[K, V]) Keys() []K
- func (m *OrderedMap[K, V]) Lookup(key K) (V, bool)
- func (m *OrderedMap[K, V]) Values() []V
- type OrderedMapEntry
Constants ¶
const ( ModuleFileName = "MODULE" ModuleSyntaxVersion = 3 BuildDirName = "BUILD" // DepsDirName is directory that dependencies are stored in. DepsDirName = "DEPS" WarningFileName = "WARNING.readme.txt" )
ModuleFileName is the name of the file describing each module.
Variables ¶
var FlagNoWorkspaceChecks = false
Functions ¶
func CheckWorkspace ¶
func CheckWorkspace()
func CopyDirRecursively ¶
Copies a directory recursing into its inner directories
func EnsureManagedDir ¶
func EnsureManagedDir(dir string)
func GetModuleRoot ¶
func GetModuleRoot() string
GetModuleRoot returns the root directory of the current module.
func GetModuleRootForPath ¶
func GetWorkingDir ¶
func GetWorkingDir() string
GetWorkingDir returns the current working directory.
func GetWorkspaceRoot ¶
func GetWorkspaceRoot() string
GetWorkspaceRoot returns the root directory of the current workspace (i.e., top-level module).
func MappedSlice ¶
Maps the input slice using the provided mapping function.
func OrderedKeys ¶
func OrderedKeys[K constraints.Ordered, V any](m map[K]V) []K
Convenience function, returning the list of ordered keys of the input map.
func OrderedSlice ¶
func OrderedSlice[V constraints.Ordered](values []V) []V
Returns the ordered copy of the provided slice, the values are shallow-copied.
func OrderedValues ¶
func OrderedValues[K constraints.Ordered, V any](m map[K]V) []V
Convenience function, returning the list of values ordered by their keys.
func SliceOrderedBy ¶
func SliceOrderedBy[V any, K constraints.Ordered](values []V, key func(v *V) K) []V
Returns the ordered copy of the provided slice, ordering is done using the key function.
func VersionTriplet ¶
func VersionTriplet() [3]uint
func WalkSymlink ¶
WalkSymlink works like filepath.Walk but also accepts symbolic links as `root`.
Types ¶
type OrderedMap ¶
type OrderedMap[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
OrderedMap is a map supporting iteration ordered by the key.
In addition, the map aborts on an attempt to override a key. This behavior is configurable, and can be turned off.
func NewOrderedMap ¶
func NewOrderedMap[K constraints.Ordered, V any]() OrderedMap[K, V]
Instantiates an empty OrderedMap object.
func NewOrderedMapFrom ¶
func NewOrderedMapFrom[K constraints.Ordered, V any](raw map[K]V) OrderedMap[K, V]
Instantiates a new OrderedMap from a given conventional map by shallow-copying both the keys and the values.
func (*OrderedMap[K, V]) AllowOverrides ¶
func (m *OrderedMap[K, V]) AllowOverrides()
Allow key overrides of the keys.
func (*OrderedMap[K, V]) Entries ¶
func (m *OrderedMap[K, V]) Entries() []OrderedMapEntry[K, V]
Returns the list of entries ordered by keys.
func (*OrderedMap[K, V]) Get ¶
func (m *OrderedMap[K, V]) Get(key K) V
Performs a lookup of the key, and aborts if the key is not found.
func (*OrderedMap[K, V]) Insert ¶
func (m *OrderedMap[K, V]) Insert(key K, value V)
Insert a (key, value) pair.
func (*OrderedMap[K, V]) Keys ¶
func (m *OrderedMap[K, V]) Keys() []K
Returns the ordered list of map keys.
func (*OrderedMap[K, V]) Lookup ¶
func (m *OrderedMap[K, V]) Lookup(key K) (V, bool)
Performs a lookup of the key, similar to `v, ok := m[k]`.
func (*OrderedMap[K, V]) Values ¶
func (m *OrderedMap[K, V]) Values() []V
Returns the values of entries ordered by their keys.
type OrderedMapEntry ¶
type OrderedMapEntry[K constraints.Ordered, V any] struct { Key K Value V }
OrderedMapEntry is an accessor into a single (key, value) pair of the map.
func OrderedEntries ¶
func OrderedEntries[K constraints.Ordered, V any](m map[K]V) []OrderedMapEntry[K, V]
Convenience function, returning the list of ordered entries of the input map.