Documentation
¶
Index ¶
- Variables
- func AddPath(newpath string) bool
- func BadExit(reason string, err error)
- func Exit(reason string, err error)
- func FullPath(p string) string
- func Get(flag string) string
- func GetAppname() (string, error)
- func GetPanic(flag string) string
- func GetUsername() string
- func GoodExit(reason string)
- func If(key string) bool
- func Init(appname, version, buildtime string, fromargv []string, goodFunc func(string), ...)
- func InitValid() bool
- func LoadAppENV(appname string) error
- func LoadENV(filename string) error
- func LoadEtc() error
- func PrintTable() string
- func RelPath(p string) string
- func Save() error
- func Set(varname string, newValue string) error
- func SetGlobal(global string, varname string, newValue string) error
- func True(flag string) bool
- func Verbose() bool
- type Key
- func (*Key) Descriptor() ([]byte, []int)deprecated
- func (x *Key) GetGlobal() string
- func (x *Key) GetHelp() string
- func (x *Key) GetValue() string
- func (x *Key) GetVar() string
- func (*Key) ProtoMessage()
- func (x *Key) ProtoReflect() protoreflect.Message
- func (x *Key) Reset()
- func (x *Key) String() string
- type KeyScanner
- type Keys
- func (x *Keys) All() *KeyScanner
- func (x *Keys) Append(y *Key)
- func (x *Keys) AppendByVar(y *Key) bool
- func (x *Keys) Clone(y *Key) *Key
- func (x *Keys) CloneByVar(y *Key) bool
- func (x *Keys) Delete(y *Key) bool
- func (x *Keys) DeleteByVar(s string) bool
- func (*Keys) Descriptor() ([]byte, []int)deprecated
- func (x *Keys) FindByVar(s string) *Key
- func (v *Keys) FormatJSON() string
- func (v *Keys) FormatTEXT() string
- func (x *Keys) GetFilename() string
- func (x *Keys) GetHomeDir() string
- func (x *Keys) GetInit() bool
- func (x *Keys) GetKeys() []*Key
- func (x *Keys) GetUuid() string
- func (x *Keys) GetVersion() string
- func (x *Keys) InsertByVar(y string) *Key
- func (x *Keys) IterAll() iter.Seq[*Key]
- func (x *Keys) IterByVar() iter.Seq[*Key]
- func (x *Keys) Len() int
- func (v *Keys) Marshal() ([]byte, error)
- func (v *Keys) MarshalJSON() ([]byte, error)
- func (*Keys) ProtoMessage()
- func (x *Keys) ProtoReflect() protoreflect.Message
- func (x *Keys) Reset()
- func (x *Keys) SortByVar() *KeyScanner
- func (pb *Keys) SortVar()
- func (x *Keys) String() string
- func (v *Keys) Unmarshal(data []byte) error
- func (v *Keys) UnmarshalJSON(data []byte) error
- func (v *Keys) UnmarshalTEXT(data []byte) error
- type KeysScanner
Constants ¶
This section is empty.
Variables ¶
var APPNAME string
these are normally what are sent from ldflags
var BUILDTIME string
var ErrInit error = fmt.Errorf("lib/env has not been initialized")
var File_key_proto protoreflect.FileDescriptor
var NotInitialized error = errors.New("your application config not initialized")
var VERSION string
Functions ¶
func GetAppname ¶
func GetUsername ¶
func GetUsername() string
func GoodExit ¶
func GoodExit(reason string)
argv normally sets these callbacks argv has timing set from when os.Args was parsed
func Init ¶
func Init(appname, version, buildtime string, fromargv []string, goodFunc func(string), badFunc func(string, error))
this is an experiment at this point to see how this turns out normally called by "argv" (go.wit.com/lib/protobuf/argvpb)
func LoadAppENV ¶ added in v0.0.11
func PrintTable ¶
func PrintTable() string
Types ¶
type Key ¶
type Key struct {
Var string `protobuf:"bytes,1,opt,name=var,proto3" json:"var,omitempty"` // ENV var name `autogenpb:unique` `autogenpb:sort`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // ENV value name
Global string `protobuf:"bytes,3,opt,name=global,proto3" json:"global,omitempty"` // where ENV was defined in application OS settings
Help string `protobuf:"bytes,4,opt,name=help,proto3" json:"help,omitempty"` // text for explaining the ENV key/value
// contains filtered or unexported fields
}
func (*Key) Descriptor
deprecated
func (*Key) ProtoMessage ¶
func (*Key) ProtoMessage()
func (*Key) ProtoReflect ¶
func (x *Key) ProtoReflect() protoreflect.Message
type KeyScanner ¶
func (*KeyScanner) Next ¶
func (it *KeyScanner) Next() *Key
Next() returns the next thing in the array
func (*KeyScanner) Scan ¶
func (it *KeyScanner) Scan() bool
type Keys ¶
type Keys struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:uuid:7a8aaf7f-9851-42f0-89eb-434d2e51f5bb`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v0.0.1 go.wit.com/lib/env`
Keys []*Key `protobuf:"bytes,3,rep,name=keys,proto3" json:"keys,omitempty"`
Filename string `protobuf:"bytes,4,opt,name=filename,proto3" json:"filename,omitempty"` // can store where the filename is so that saves can be automated
Init bool `protobuf:"varint,5,opt,name=init,proto3" json:"init,omitempty"` // can store where the filename is so that saves can be automated
HomeDir string `protobuf:"bytes,6,opt,name=homeDir,proto3" json:"homeDir,omitempty"` // always need this. Converts "~" into "/home/turing"
// contains filtered or unexported fields
}
func (*Keys) All ¶
func (x *Keys) All() *KeyScanner
func (*Keys) Append ¶
a Append() shortcut (that does Clone() with a mutex) notsure if it really works doesn't allow nil
func (*Keys) AppendByVar ¶
func (*Keys) CloneByVar ¶
func (*Keys) DeleteByVar ¶
func (*Keys) Descriptor
deprecated
func (*Keys) FormatTEXT ¶
apparently this isn't stable, but it's awesomely better https://protobuf.dev/reference/go/faq/#unstable-text it's brilliant for config files!
func (*Keys) GetFilename ¶
func (*Keys) GetHomeDir ¶ added in v0.0.9
func (*Keys) GetVersion ¶
func (*Keys) InsertByVar ¶
returns a Key if Var matches, otherwise create
func (*Keys) ProtoMessage ¶
func (*Keys) ProtoMessage()
func (*Keys) ProtoReflect ¶
func (x *Keys) ProtoReflect() protoreflect.Message
func (*Keys) SortByVar ¶
func (x *Keys) SortByVar() *KeyScanner
func (*Keys) UnmarshalTEXT ¶
unmarshalTEXT. This reads the .text config file back in after the user edits it
type KeysScanner ¶
func (*KeysScanner) Next ¶
func (it *KeysScanner) Next() *Keys
Next() returns the next thing in the array
func (*KeysScanner) Scan ¶
func (it *KeysScanner) Scan() bool