Documentation ¶
Index ¶
- Constants
- func FreeEnv[T any]()
- type CFArray
- type CFBool
- type CFData
- type CFDictionary
- type CFNone
- type CFNumber
- type CFReal
- type CFString
- type CFUID
- type CFValue
- type Env
- type EnvOpt
- type MetaArr
- type MetaMap
- type MetaTable
- type MetaValue
- type PlistFile
- func (pf *PlistFile) Append(value any) error
- func (pf *PlistFile) Backup() error
- func (pf *PlistFile) Free()
- func (pf *PlistFile) GetArr() CFArray
- func (pf *PlistFile) GetArrByField(field string) CFArray
- func (pf *PlistFile) GetBaseValue() CFValue
- func (pf *PlistFile) GetDict() CFDictionary
- func (pf *PlistFile) GetValue(key string) CFValue
- func (pf *PlistFile) Len() int
- func (pf *PlistFile) SafeSet(key string, value any) error
- func (pf *PlistFile) Set(value any)
- func (pf *PlistFile) SetByField(field string, value CFValue) error
- func (pf *PlistFile) SetByIdx(idx int, value any) error
- func (pf *PlistFile) Write() error
- type PosixEnvVar
- func (env *PosixEnvVar) Export(file string) error
- func (env *PosixEnvVar) Load(opt yocki.EnvVarLoadOpt) error
- func (env *PosixEnvVar) Print()
- func (env *PosixEnvVar) SafeSet(k string, v any) error
- func (env *PosixEnvVar) SafeSetL(k, v string) error
- func (env *PosixEnvVar) Set(k string, v any) error
- func (env *PosixEnvVar) SetL(k, v string) error
- func (env *PosixEnvVar) SetPath(path string) error
- func (env *PosixEnvVar) Unset(k string) error
Constants ¶
const ( CF_DICT = iota CF_ARR CF_STR CF_NUM CF_BOOL CF_DATA CF_UID CF_REAL CF_NONE )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CFDictionary ¶
type CFDictionary struct {
// contains filtered or unexported fields
}
func (CFDictionary) GetCFValue ¶
func (c CFDictionary) GetCFValue(field string) CFValue
func (CFDictionary) Set ¶
func (c CFDictionary) Set(field string, v any)
func (CFDictionary) Type ¶
func (CFDictionary) Type() uint8
type EnvOpt ¶
type MetaTable ¶
type MetaTable interface { // SetValue set MetaTable's value and have two different rules: // regedit(windows): MetaValue ✔ MetaMap ✔ MetaArr x (MetaArr not work); // plist(darwin, posix): MetaValue ✔ MetaMap ✔ MetaArr ✔ SetValue(MetaValue) // SafeSetValue set MetaTable's value when key isn't exist and have two different rules: // regedit(windows): MetaValue ✔ MetaMap ✔ MetaArr x (MetaArr not work); // plist(darwin, posix): MetaValue ✔ MetaMap ✔ MetaArr ✔ SafeSetValue(MetaValue) // GetValue return MetaValue according to key GetValue(string) MetaValue // CreateSubTable have two different effect: // regedit(windows): create sub key and written file depond on its feture. // plist(darwin, posix): create sub element of map or array, but not be saved automatically // comparing regedit. It's required to call Write method save manually. CreateSubTable(string) MetaTable // Write to persist MetaValue in disk. // note: The regedit (windows) is written when it is created, // and this method is only valid for plist (darwin, posix). // The regedit is just an empty method. Write() error // Backup save a copy which could restore MetaValue Backup() error // Close to free MetaTable memory Close() }
MetaTable is an interface to abstract plist(darwin) and regedit(windows). In other posix os, uniform use of plist as MetaTable interface implement
type PlistFile ¶
type PlistFile struct {
// contains filtered or unexported fields
}
PlistFile manage plist, which serves for PosixMetaTable
func CreatePlistFile ¶
CreatePlistFile create specify plist when plist isn't exist
func OpenPlistFile ¶
OpenPlistFile open specify plist
func (*PlistFile) GetArr ¶
GetDict returns CFArray. If not exist in plist, it'll return a empty CFArray.
func (*PlistFile) GetArrByField ¶
GetArrByField return CFArray according to field
func (*PlistFile) GetBaseValue ¶
GetBaseValue returns CFValue. If not exist in plist, it'll return CFNone.
func (*PlistFile) GetDict ¶
func (pf *PlistFile) GetDict() CFDictionary
GetDict returns CFDictionary. If not exist in plist, it'll return a empty CFDictionary.
func (*PlistFile) Len ¶
Len return plist length. Length of array or map depend on elements amount. For other type that include string, date, number and so on, it ever returns 1.
func (*PlistFile) SetByField ¶
SetByField set element in sprcify field, which support recurse and meant that you can set a.b.c field.
type PosixEnvVar ¶
type PosixEnvVar struct{}
func NewEnvVar ¶
func NewEnvVar() *PosixEnvVar
func (*PosixEnvVar) Export ¶
func (env *PosixEnvVar) Export(file string) error
export current enviroment string into specify file
func (*PosixEnvVar) Load ¶
func (env *PosixEnvVar) Load(opt yocki.EnvVarLoadOpt) error
load exported env from disk
func (*PosixEnvVar) SafeSet ¶
func (env *PosixEnvVar) SafeSet(k string, v any) error
set global enviroment variable when key isn't exist
func (*PosixEnvVar) SafeSetL ¶
func (env *PosixEnvVar) SafeSetL(k, v string) error
set local enviroment variable when key isn't exist
func (*PosixEnvVar) Set ¶
func (env *PosixEnvVar) Set(k string, v any) error
set global enviroment variable
func (*PosixEnvVar) SetL ¶
func (env *PosixEnvVar) SetL(k, v string) error
set local enviroment variable
func (*PosixEnvVar) SetPath ¶
func (env *PosixEnvVar) SetPath(path string) error
SetPath set operate target: posix: /etc/enviroment, this only is empty method.
func (*PosixEnvVar) Unset ¶
func (env *PosixEnvVar) Unset(k string) error
unset (delete) global enviroment variable