Documentation
¶
Index ¶
- func KeyExists(key registry.Key, path string) bool
- type Key
- func (k *Key) CloneKey() (*Key, error)
- func (k *Key) Close() error
- func (k *Key) CreateKey(path string, access uint32) (*Key, error)
- func (k *Key) CreateValue(key string, value any) error
- func (k *Key) CreateValueMany(data map[string]any) error
- func (k *Key) DeepLoad() error
- func (k *Key) DeleteKey(path string) error
- func (k *Key) DeleteValue(name string) error
- func (k *Key) ExportJson() ([]byte, error)
- func (k *Key) GetValue(name string) (any, error)
- func (k *Key) GetValueAndNames() (map[string]any, error)
- func (k *Key) Load() error
- func (k *Key) LoadWithLimit(limit int) error
- func (k *Key) Walk(fn func(k *Key) error) error
- func (k *Key) WalkReverse(fn func(k *Key) error) error
- type SubKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Key ¶ added in v1.0.1
type Key struct {
Handle registry.Key // Parent registry key
RootKey registry.Key // The top-most level key, e.g. HKCU, HKLM
Path string // Path of the parent registry key
Subkeys map[string]*SubKey // Map of subkeys from the opened registry key
Values map[string]any // Values inside the parent registry key
Permission uint32 // Permission used for the key
Loaded bool // Represents if the key has had its values / subkeys loaded
}
Represents a registry key layout
func (*Key) CreateKey ¶ added in v1.0.1
Creates a new key. This function will error if the key already exists, unlike the std package version where it will silently open regardless. Enforces correctness and guards.
func (*Key) CreateValue ¶ added in v1.0.1
Creates a value in accordance with the std registry package constraints. Underlying value type is reflected. Supports all known types of values.
func (*Key) CreateValueMany ¶ added in v1.0.1
Loops through the provided map and calls CreateValue(...) to create all key=>values in the current key object.
func (*Key) DeepLoad ¶ added in v1.0.1
Recursively loads the current key and all of its descendant subkeys. It calls Load() on the current key if it has not been loaded yet, then traverses all loaded subkeys and attempts to load each child key recursively.
func (*Key) DeleteKey ¶ added in v1.0.1
Checks if the key exists and deletes it. Will return an error if the key does not exist. Do not use this on keys that have subkeys. For this, use DeleteKeysAll()
func (*Key) DeleteValue ¶ added in v1.0.1
Safely checks if the value exists and deletes it.
func (*Key) ExportJson ¶ added in v1.0.1
Marshals the current key object into JSON.
func (*Key) GetValue ¶ added in v1.0.1
Obtains a value from the key `name`. It will get any type from the registry without needing to specify the specific registry.GetXValue(...) functions.
func (*Key) GetValueAndNames ¶ added in v1.0.1
Obtains all key=>value pairs from the specified key
func (*Key) Load ¶ added in v1.0.1
Calls LoadWithLimit(0) for an explicit way to load keys with no limit.
func (*Key) LoadWithLimit ¶ added in v1.0.1
Will get the current key you have opened and then enumerate it for futher subkeys and it's children. `limit` is an integer to specify if you want to only load x amount of items, not to be confused with loading x amount of keys inside keys from the current key. LoadWithLimit will only do a shallow read one level down. If you want full, recursive deep loading see DeepLoad
func (*Key) Walk ¶ added in v1.0.1
Recursively traverses the key and all of its loaded subkeys from the top down, applying the provided function `fn` to each *Key in depth-first order.
If the key has not been loaded yet, Walk will call Load() automatically to populate subkeys before continuing traversal.
If fn returns an error at any point, Walk stops immediately and returns that error.