Documentation
¶
Index ¶
- Constants
- Variables
- func AddPair(db *sql.DB, table string, id int, str string) (res int, err error)
- func AddPairNoID(db *sql.DB, table string, str string) (int, error)
- func AddWtParams(db *sql.DB, table string, fields []string, values []string, yes2all bool) (int, error)
- func AddWtParamsUniq(db *sql.DB, table string, fields []string, values []string, yes2all bool) (int, error)
- func AppUpgrade(db *sql.DB, prefix string, ver string, server *chan string, ch chan bool)
- func Authenticate(db *sql.DB, username, password string) error
- func ChkCfmNPrompt(noti, exception string) bool
- func ChooseInts(arr [][]string, notif string) (id int)
- func ChooseMaps(choices []map[string]string, sep string, indI ...string) int
- func ChoosePair(db *sql.DB, table string) (int, error)
- func ChoosePairNAddAssociated(db *sql.DB, idTable, strTable string, uniq bool) (int, error)
- func ChoosePairOrAdd(db *sql.DB, table string, uniq bool) (int, error)
- func ChooseStrings(choices []string) (int, string)
- func ChooseStringsWtIDs(fL func() int, fI func(int) int, fV func(int) string, notif string) (res int)
- func Connect() (*sql.DB, error)
- func ConnectWtCfg(file string) (*sql.DB, error)
- func ConnectWtParam(user, pass, ip, database string) (db *sql.DB, err error)
- func ConnectWtPath(path string) (*sql.DB, error)
- func DeleteWtID(db *sql.DB, table, id string) error
- func DeleteWtParams(db *sql.DB, table, where string) error
- func DiffDate(dateO, dateN string) (diff int, ok bool)
- func FileWrite(file string, bytes []byte, createIfNeeded bool) error
- func FindStrMap(obj interface{}, key string) (interface{}, bool)
- func GetDate(info string) string
- func GetPair(db *sql.DB, table, id, from, to string) (string, error)
- func GetPairID(db *sql.DB, table string, str string) (int, error)
- func GetPairIDFromInt(db *sql.DB, table string, val int) (int, error)
- func GetPairInt(db *sql.DB, table string, id string) (int, error)
- func GetPairStr(db *sql.DB, table string, id string) (string, error)
- func GetPairStrFromInt(db *sql.DB, table string, id int) (string, error)
- func InitLogger(out *os.File) error
- func Locate(db *sql.DB, table string, str string) (id int, err error)
- func Log(out ...interface{})
- func LogErr(err error)
- func LogErrFatal(err error)
- func LogErrPrint(err error)
- func LogErrPrintWtInfo(info string, err error)
- func LogErrWtInfo(info string, err error)
- func LogFatal(out ...interface{})
- func LogPrint(out ...interface{})
- func LogPrintWtTime(out ...interface{})
- func LogWtTime(out ...interface{})
- func PromptInt(pi string) (res int, err error)
- func PromptIntStr(pi string, ps string) (i int, s string)
- func PromptPwd(ps string) string
- func PromptStr(ps string) string
- func RangeStrMap(obj interface{}, fun func(k string, v interface{}) bool) bool
- func RestGet(url string, authInfo AuthInfo, bodyReq io.Reader) (bodyMap interface{}, errNo int, err error)
- func RestGetOrPostSaveFile(method, url string, authInfo AuthInfo, magic []byte, file string) (errNo int, err error)
- func RestGetOrPostWtMagic(method, url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (bodyMap interface{}, errNo int, err error)
- func RestGetOrPostWtMagicNFileNHdr(method, url string, authInfo AuthInfo, magic []byte, fType, fName string, ...) (bodyMap interface{}, errNo int, err error)
- func RestGetWtMagic(url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (bodyMap interface{}, errNo int, err error)
- func RestPostWtMagic(url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (bodyMap interface{}, errNo int, err error)
- func Rows2Strings(db *sql.DB, rows *sql.Rows) (res [][]string, err error)
- func Search(db *sql.DB, table string, cri string, sel []string, more string) ([][]string, error)
- func ShowArrln(arr []string)
- func ShowByteln(ps []byte)
- func ShowSthln(sth interface{})
- func ShowStr(ps ...interface{})
- func ShowStrln(ps ...interface{})
- func ShowWtFmt(fs string, sth ...interface{})
- func TranDate(date string) string
- func TranSize(b int64, precision int, space bool) string
- func UpdatePairID(db *sql.DB, table string, idOld, idNew string) error
- func UpdatePairWtParams(db *sql.DB, table string, id, str string) error
- func UpdateWtParams(db *sql.DB, table, cri string, fields, values []string, yes2all bool) error
- func XMLRead(file string, data interface{}, _ bool) error
- func XMLWrite(file string, data interface{}, createIfNeeded bool, indent string) error
- func XMLWriteNoCreate(file string, cfg interface{}, indent string) error
- func XMLsReadDefault(path, file string, cfg interface{}, createIfNeeded bool) (pathFound string, err error)
- func XMLsReadDefaultNoCreate(path, file string, cfg interface{}) (string, error)
- type AuthInfo
- type PairsInt
- type PairsStr
Constants ¶
const ( // DefID is the default ID DefID = 0 // AllID stands for all items AllID = DefID - 1 // InvalidID better to be negative to be different from a normal ID // it is used as indexes into slices, too InvalidID = DefID - 2 //pairs defined some related )
const ( AUTH_NONE = iota AUTH_PLAIN AUTH_BASIC AUTH_DIGEST METHOD_GET = "GET" METHOD_PUT = "PUT" METHOD_POST = "POST" METHOD_DEL = "DELETE" )
const ( // TblCHORE contains misc items TblCHORE = "chore" // TblTOOL contains xTS names TblTOOL = "tool" // TblVER contains versions of xTS TblVER = "ver" // TblANDROID contains android versions TblANDROID = "android" // TblGOOGLE contains xTS requirements TblGOOGLE = "google" // TblPRODUCT contains product names TblPRODUCT = "product" // TblPRODGLE contains matches of products and requirements TblPRODGLE = "prodgle" // TblPRODFO contains matches of products and info TblPRODFO = "prodfo" // TblBIT contains bit info TblBIT = "bit" // TblPHASE contains phase info TblPHASE = "phase" // TblTEAM contains team names TblTEAM = "team" // TblCONTACTS contains contact info TblCONTACTS = "contacts" // TblWEEKLYTASKBARS contains bars in report TblWEEKLYTASKBARS = "weeklyTaskBars" // TblWEEKLYTASKTITLES contains titles in report TblWEEKLYTASKTITLES = "weeklyTaskTitles" // TblWEEKLYTASKCURR contains titles of current week TblWEEKLYTASKCURR = "weeklyTaskCurr" // TblWEEKLYTASKNEXT contains titles of next week TblWEEKLYTASKNEXT = "weeklyTaskNext" // TblWEEKLYTASKDESC contains descriptions of tasks TblWEEKLYTASKDESC = "weeklyTaskDesc" // TblWEEKLYTASKWORK contains items of tasks TblWEEKLYTASKWORK = "weeklyTaskWork" // FldID is the name of field id FldID = "id" // FldSTR is the name of field str FldSTR = "str" // FldPHASE is the name of field phase FldPHASE = "phase" // FldTOOL is the name of field tool FldTOOL = "tool" // FldANDROID is the name of field android FldANDROID = "android" // FldPRODUCT is the name of field product FldPRODUCT = "product" // FldGOOGLE is the name of field google FldGOOGLE = "google" // FldVER is the name of field versions FldVER = "ver" // FldREQ is the name of field requirements FldREQ = "req" // FldEXP is the name of field expiry FldEXP = "exp" // FldBIT is the name of field bit FldBIT = "bit" // contacts // FldLEADER is the name of field leader FldLEADER = "leader" // FldNUMBER is the name of field number FldNUMBER = "number" // FldNAME is the name of field name FldNAME = "name" // FldTEAM is the name of field team FldTEAM = "team" // FldEXT is the name of field ext FldEXT = "ext" // FldPHONE is the name of field phone FldPHONE = "phone" // FldMAIL is the name of field mail FldMAIL = "mail" // FldLDAP is the name of field ldap FldLDAP = "ldap" // FldUID is the name of field uid FldUID = "uid" // FldNICK is the name of field nick FldNICK = "nick" // FldSECTION is the name of field section FldSECTION = "section" )
Variables ¶
var ( // ErrNoValidResults stands for no valid results ErrNoValidResults = errors.New("No Valid results") // ErrOutOfBound stands for out of bound ErrOutOfBound = errors.New("Out of bound") // ErrInvalidInput stands for invalid input ErrInvalidInput = errors.New("Invalid input") // ErrInExistence stands for result from input already in existence ErrInExistence = errors.New("In Existence") // ErrAccess stands for access failure, such as privilege, collision ErrAccess = errors.New("Access failure") )
var ( // Debugging marks debugging mode Debugging bool // whether more debug procedures // Verbose marse debugging output level Verbose = 0 // ChoiceNotification is printed when user needs to choose from choices ChoiceNotification = "Your choice is: " )
Functions ¶
func AddPairNoID ¶
AddPairNoID adds an item with value, where ID should be auto generated
func AddWtParams ¶
func AddWtParams(db *sql.DB, table string, fields []string, values []string, yes2all bool) (int, error)
AddWtParams adds "values" to "fields", no matter whether duplicate records in existence. Parameter yes2all = no confirmation in debug mode. Always no confirmation in non-debug mode.
func AddWtParamsUniq ¶
func AddWtParamsUniq(db *sql.DB, table string, fields []string, values []string, yes2all bool) (int, error)
AddWtParamsUniq adds "values" to "fields", if no duplicate records in existence. Parameter yes2all = no confirmation in debug mode. Always no confirmation in non-debug mode.
func AppUpgrade ¶
AppUpgrade checks for updates and applies the update automatically, which will work next time the app is run. ch: 1st=false, if wrong server URL configured.
2nd=false, if other configurations wrong, or update check fails.
func Authenticate ¶
Authenticate checks whether authenticated. Return value: nil if true.
func ChkCfmNPrompt ¶
ChkCfmNPrompt checks defaults and return false only when user replied exception program exits when user replied 'q' or 'e' no more confirmations when user replied 'a' or 'c' verbose set when user replied a number, in which case the prompt will show again
func ChooseInts ¶
ChooseInts asks user to choose from a slice Parameters. arr[][0]=id. arr[][1]=string
func ChooseMaps ¶
ChooseMaps asks user to choose from a slice of map of string to string parameters: slice.
separator between two piece of information. index(-es) into the map (to be contacted) to be information of each item, or separators between two indexes.
example: (c, ";", "a", "c") with
c index name value 0 a A 0 c C 1 a B 1 c D will print 0: A;C 1: B;D
func ChoosePair ¶
ChoosePair asks user to choose from a table by ID - value pairs.
func ChoosePairNAddAssociated ¶
ChoosePairNAddAssociated asks user to choose by idTable - strTable pairs,
where idTable.str == strTable.id (return value)
Parameter uniq is of no use
func ChoosePairOrAdd ¶
ChoosePairOrAdd asks user to choose from a table by ID - value pairs,
allowing to add one new.
func ChooseStrings ¶
ChooseStrings asks user to choose from a slice return values: index (InvalidID if not a valid one) and string
func ChooseStringsWtIDs ¶
func ChooseStringsWtIDs(fL func() int, fI func(int) int, fV func(int) string, notif string) (res int)
ChooseStringsWtIDs is for general usage to ask user to choose from a slice or anything parameters.
fL=quantity of elements fI=get index to match user's input fV=get message to show for each index notif=notification string for user
func Connect ¶
Connect connects to the database using parameters from eztools.xml root element is named "root", elements include "ip", "db", "user" and "pass"
func ConnectWtCfg ¶
ConnectWtCfg connects to the database using parameters from an xml file root element is named "root", elements include "ip", "db", "user" and "pass"
func ConnectWtParam ¶
ConnectWtParam connects to the database using parameters.
func ConnectWtPath ¶
ConnectWtPath connects to the database using path as config file
func DeleteWtParams ¶
DeleteWtParams deletes items with specified WHERE clause
func FindStrMap ¶
FindStrMap find string key in map[string]interface{} obj,
returning the value and true or nil and false.
func GetPair ¶
GetPair gets "to" field from "from" field in "table" When multiple results got, the first one will be taken. return value error = from db.Query;
ErrNoValidResults when no valid results got, and LogErrPrint will be called.
func GetPairID ¶
GetPairID gets ID (int) from value (string) When multiple results got, the first one will be taken.
func GetPairIDFromInt ¶
GetPairIDFromInt gets ID (int) from value (int) When multiple results got, the first one will be taken.
func GetPairInt ¶
GetPairInt gets value (int) from ID (string)
func GetPairStr ¶
GetPairStr gets value (string) from ID (string)
func GetPairStrFromInt ¶
GetPairStrFromInt gets value (string) from ID (int)
func LogErrPrintWtInfo ¶
LogErrPrintWtInfo logs and prints error with information string
func LogErrWtInfo ¶
LogErrWtInfo logs error with information string
func LogPrintWtTime ¶
func LogPrintWtTime(out ...interface{})
LogPrintWtTime logs and prints a string with time
func PromptIntStr ¶
PromptIntStr prompts user and gets two inputs Return values. zero values are default
func RangeStrMap ¶
RangeStrMap iterate through map[string]interface{} obj, calling fun for
each element recursively. When fun returns true, it stops. false is returned if no element found.
func RestGet ¶
func RestGet(url string, authInfo AuthInfo, bodyReq io.Reader) (bodyMap interface{}, errNo int, err error)
RestGet sends Restful API request and returns the result.
func RestGetOrPostSaveFile ¶
func RestGetOrPostSaveFile(method, url string, authInfo AuthInfo, magic []byte, file string) (errNo int, err error)
RestGetOrPostBodyBytes sends Restful API request as a method and returns the result.
A magic string can be listed to be stripped in the beginning of the result.
func RestGetOrPostWtMagic ¶
func RestGetOrPostWtMagic(method, url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (bodyMap interface{}, errNo int, err error)
RestGetOrPostWtMagic sends Restful API request as a method and returns the result.
A magic string can be listed to be stripped in the beginning of the result. If magic string is assigned but not found in the result, the result will not be parsed. If failure response received, bodyMap is slice of byte, copying the failure body.
func RestGetOrPostWtMagicNFileNHdr ¶
func RestGetOrPostWtMagicNFileNHdr(method, url string, authInfo AuthInfo, magic []byte, fType, fName string, hdrs map[string]string) (bodyMap interface{}, errNo int, err error)
RestGetOrPostWtMagicNFileNHdr sends Restful API request as a method and returns the result.
Use this to specify a file with name and type to be sent as body, and/or extra headers. If something wrong with the file, a request will be sent without it anyway. A magic string can be listed to be stripped in the beginning of the result. If magic string is assigned but not found in the result, the result will not be parsed. If failure response received, bodyMap is slice of byte, copying the failure body.
func RestGetWtMagic ¶
func RestGetWtMagic(url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (bodyMap interface{}, errNo int, err error)
RestGetWtMagic sends Restful API request as GET and returns the result.
A magic string can be listed to be stripped in the beginning of the result. If magic string is assigned but not found in the result, the result will not be parsed.
func RestPostWtMagic ¶
func RestPostWtMagic(url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (bodyMap interface{}, errNo int, err error)
RestPostWtMagic sends Restful API request as POST and returns the result.
A magic string can be listed to be stripped in the beginning of the result. If magic string is assigned but not found in the result, the result will not be parsed.
func Rows2Strings ¶
Rows2Strings returns arrays from rows Parameter db not used
func Search ¶
Search gets values of fields "sel" from "table", using "cri" as "WHERE",
with "more" appended to SQL command.
Parameters: more: will not be prefixed with space automatically
func ShowArrln ¶
func ShowArrln(arr []string)
ShowArrln prints a slice in one line with a line break
func ShowByteln ¶
func ShowByteln(ps []byte)
ShowByteln prints byte slice as string with a line break
func ShowSthln ¶
func ShowSthln(sth interface{})
ShowSthln prints anything with struct names and a line break
func ShowWtFmt ¶
func ShowWtFmt(fs string, sth ...interface{})
ShowWtFmt prints with format string like printf
func TranDate ¶
TranDate removes minuses from date string return current date if empty string as param
func TranSize ¶
TranSize shows the number as file size format input params: b=number; precision=how many number to keep lower than point;
space=whether a space is put between number and unit
copied from https://programming.guide/go/formatting-byte-size-to-human-readable-format.html
func UpdatePairID ¶
UpdatePairID updates ID
func UpdatePairWtParams ¶
UpdatePairWtParams updates value by ID
func UpdateWtParams ¶
UpdateWtParams updates "fields" in "table" with "values", using "cri" as "WHERE". Parameter yes2all = no confirmation in debug mode. Always no confirmation in non-debug mode.
func XMLWrite ¶
XMLWrite writes input structure to file this reformats the file with indent provided
func XMLWriteNoCreate ¶
XMLWriteNoCreate writes config file from input structure by a full path (with .xml extension) this reformats the file with indent provided
func XMLsReadDefault ¶
func XMLsReadDefault(path, file string, cfg interface{}, createIfNeeded bool) ( pathFound string, err error)
XMLsReadDefault reads a config file
func XMLsReadDefaultNoCreate ¶
XMLsReadDefaultNoCreate reads config file into input structure from given path, or given file name (plus .xml) under current dir or home dir returns full file name with path
Types ¶
type PairsInt ¶
type PairsInt struct {
// contains filtered or unexported fields
}
PairsInt is a collection of pairsI
func GetSortedPairsInt ¶
GetSortedPairsInt returns all sorted PairsInt from input table
type PairsStr ¶
type PairsStr struct {
// contains filtered or unexported fields
}
PairsStr is a collection of pairs
func GetSortedPairsStr ¶
GetSortedPairsStr returns all sorted PairsStr from input table
func (*PairsStr) FindStr ¶
FindStr find the first ID where str matches input return value: ErrNoValidResults when none found