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 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) (res int)
- 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 DeleteWtID(db *sql.DB, table, id string) error
- func DeleteWtParams(db *sql.DB, table, where string) 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 string)
- 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 string)
- func LogPrint(out ...interface{})
- func LogPrintWtTime(out string)
- 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 RestGetOrPostWtMagic(method, url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (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 string)
- func ShowStrln(ps string)
- func TranDate(date string) 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) error
- func XMLWriteNoCreate(file string, cfg interface{}) 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 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" )
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 for input already in existence ErrInExistence = errors.New("In Existence") )
var ( // Debugging marks debugging mode Debugging bool // whether more debug procedures // Verbose marse debugging output level Verbose = 0 )
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.
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 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
func ChooseStringsWtIDs ¶ added in v0.0.2
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 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 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
func LogErrWtInfo ¶
LogErrWtInfo logs error with information
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 RestGetOrPostWtMagic ¶
func RestGetWtMagic ¶
func RestGetWtMagic(url string, authInfo AuthInfo, bodyReq io.Reader, magic []byte) (bodyMap interface{}, errNo int, err error)
RestGetWtMagic sends Restful API request 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 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 ShowSthln ¶
func ShowSthln(sth ...interface{})
ShowSthln prints all kinds of stuffs with line feed
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 XMLWriteNoCreate ¶ added in v1.1.1
XMLWriteNoCreate writes config file from input structure by a full path (with .xml extension)
func XMLsReadDefault ¶
func XMLsReadDefault(path, file string, cfg interface{}, createIfNeeded bool) ( pathFound string, err error)
XMLsReadDefault reads a config file
func XMLsReadDefaultNoCreate ¶ added in v1.1.1
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