sizlib

package
v0.7.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 27 Imported by: 17

Documentation

Index

Constants

View Source
const ISO8601 = "2006-01-02T15:04:05.99999Z07:00"

ISO format for date

View Source
const ISO8601output = "2006-01-02T15:04:05.99999-0700"

ISO format for date

View Source
const ReturnPacked = true

Variables

View Source
var DbBeginQuote = `"`
View Source
var DbEndQuote = `"`
View Source
var IsBSD = false
View Source
var IsLinux = true
View Source
var IsUnix = true
View Source
var IsWindows = false

Functions

func Basename

func Basename(fn string) (bn string)

------------------------------------------------------------------------------------------------- xyzzy - str. Return the basename from a file path. This is the last component with the directory path stripped off. File extension removed. -------------------------------------------------------------------------------------------------

func BasenameExt

func BasenameExt(fn string) (bn string)

------------------------------------------------------------------------------------------------- xyzzy - str. With file extension -------------------------------------------------------------------------------------------------

func ConnectToDb

func ConnectToDb(auth string) *sql.DB

func DbFprint

func DbFprint(db bool, fp io.Writer, format string, arg ...interface{})

func DbPrint

func DbPrint(db bool, format string, arg ...interface{})

func DbValueFromRow

func DbValueFromRow(rvdata []map[string]interface{}, row int, col string, def string) (rv string)

func DbValueIsNull

func DbValueIsNull(rvdata []map[string]interface{}, row int, col string) (rv bool)

func Dirname

func Dirname(fn string) (bn string)

Return the directory part of a file name

func DumpVar

func DumpVar(v interface{})

------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------

func EscapeDoubleQuote

func EscapeDoubleQuote(s string) string

------------------------------------------------------------------------------------------------

func EscapeError

func EscapeError(err error) string

func Exists

func Exists(name string) bool

------------------------------------------------------------------------------------------------- Tested Exists reports whether the named file or directory exists. -------------------------------------------------------------------------------------------------

func ExistsGetUDate

func ExistsGetUDate(name string) (bool, os.FileInfo)

-------------------------------------------------------------------------------------------------

type FileInfo interface {
	Name() string       // base name of the file
	Size() int64        // length in bytes for regular files; system-dependent for others
	Mode() FileMode     // file mode bits
	ModTime() time.Time // modification time
	IsDir() bool        // abbreviation for Mode().IsDir()
	Sys() interface{}   // underlying data source (can return nil)
}

Tested Exists reports whether the named file or directory exists. -------------------------------------------------------------------------------------------------

func ExistsIsDir

func ExistsIsDir(name string) bool

func ExtendData

func ExtendData(a map[string]interface{}, b map[string]interface{}) (rv map[string]interface{})

func ExtendDataS

func ExtendDataS(a map[string]string, b map[string]string) (rv map[string]string)

func ExtendStringMap

func ExtendStringMap(a map[string]string, b map[string]string) map[string]string

ExtendStringMap merges map of restuls from multiple JSON reads

func FilesMatchingPattern

func FilesMatchingPattern(dir, pattern string) []string

func FilterArray

func FilterArray(re string, inArr []string) (outArr []string)

------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------

func FindDirsWithSQLCfg

func FindDirsWithSQLCfg(pth string, ignoreDirs []string) (rv []string)

FindDirsWithSQLCfg searches a possibly recursive set of directories looking for directories containing sql-cfg*.json file.

func FindFiles

func FindFiles(pth string, ignoreDirs []string) (rv []string)

func FnToCSSClass

func FnToCSSClass(filename string) string

------------------------------------------------------------------------------------------------- xyzzy - str. Tested -------------------------------------------------------------------------------------------------

func Fopen

func Fopen(fn string, mode string) (file *os.File, err error)

func GetFile

func GetFile(fn string) string

------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------

func GetFilenames

func GetFilenames(dir string) (filenames, dirs []string)

------------------------------------------------------------------------------------------------- Get a list of filenames and directorys. xyzzy - fil. -------------------------------------------------------------------------------------------------

func GetIPFromRemoteAddr

func GetIPFromRemoteAddr(RemoteAddr string) (rv string)

GetIPFromRemoteAddr get client ip address from request

Example: ip,_,_ := net.SplitHostPort(r.RemoteAddr)

func GetImageFiles

func GetImageFiles(dir string) []string

------------------------------------------------------------------------------------------------- list of image files in a directory -------------------------------------------------------------------------------------------------

func GetLead

func GetLead() (lead string)

func HasKeys

func HasKeys(v map[string]interface{}) bool

------------------------------------------------------------------------------------------------ func HasKeys ( v map[string]Validation ) bool {

func HexSha1

func HexSha1(s string) string

func InArray

func InArray(lookFor string, inArr []string) bool

------------------------------------------------------------------------------------------------- xyzzy - str. -------------------------------------------------------------------------------------------------

func InArrayN

func InArrayN(lookFor string, inArr []string) int

func InsSel

func InsSel(db *sql.DB, sel string, ins string, mdata map[string]string) (id string)

------------------------------------------------------------------------------------------------- xyzzy-Rewrite

mdata["group_id"] = insSel ( "select \"id\" from \"img_group\" where \"group_name\" = '%{user_id%}'",

------------------------------------------------------------------------------------------------- :pgx:func InsSel(db *pgx.Conn, sel string, ins string, mdata map[string]string) (id string) {

func InsUpd

func InsUpd(db *sql.DB, ins string, upd string, mdata map[string]string)

------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------- :pgx:func InsUpd(db *pgx.Conn, ins string, upd string, mdata map[string]string) {

func IntersectData

func IntersectData(a map[string]interface{}, b map[string]interface{}) (rv map[string]interface{})

Keep the data that has common keys between 'a' and 'b', prefering data from 'b' not used at the moment.

func IsIntString

func IsIntString(s string) bool

func JSONStringToData

func JSONStringToData(s string) (theJSON map[string]interface{}, err error)

JsonStringToData convert from a string to a map[string]interface{} - parse JSON

func LeftData

func LeftData(a map[string]interface{}, b map[string]interface{}) (rv map[string]interface{})

Copy 'a', if same key in 'b', then copy data from b, prefering data from 'b'

func LowerCaseNames

func LowerCaseNames(a map[string]interface{}) (rv map[string]interface{})

------------------------------------------------------------------------------------------------ Copy 'a', then copy 'b' over 'a' Tests: t-extendData.go ------------------------------------------------------------------------------------------------ jDataDefaults = lowerCaseNames ( jDataDefaults )

func NeedRebuild

func NeedRebuild(parent string, optsRebuild bool, child string, child1 string, child2 string) bool

------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------

func ParseBool

func ParseBool(s string) (b bool)

func Qt

func Qt(format string, data map[string]string) string

Qt Quick template %{name%} gets replace with substitution from map if it is in map, else ""

func QtR

func QtR(format string, data map[string]interface{}) string

QtR uses a more liberal input for data - with the same template formatting

func ReadJSONDataWithComments

func ReadJSONDataWithComments(path string) (file []byte, err error)

ReadJSONDataWithComments read in the file and handle __LINE__, __FILE__ and comments starting with 4 slashes.

func ReadJSONPath

func ReadJSONPath(pth string) map[string]string

read JSON file to map -------------------------------------------------------------------------------------------------

func RmExt

func RmExt(filename string) string

------------------------------------------------------------------------------------------------- Tested -------------------------------------------------------------------------------------------------

func RowsToInterface

func RowsToInterface(rows *sql.Rows) ([]map[string]interface{}, string, int)

------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------- :pgx:func RowsToInterface(rows *pgx.Rows) ([]map[string]interface{}, string, int) {

func RowsToJson

func RowsToJson(rows *sql.Rows) (string, string)

------------------------------------------------------------------------------------------------- Rows to JSON -- Go from a set of "rows" returned by db.Query to a JSON string. ------------------------------------------------------------------------------------------------- :pgx:func RowsToJson(rows *pgx.Rows) (string, string) {

func RowsToJsonFirstRow

func RowsToJsonFirstRow(rows *sql.Rows) (string, string)

------------------------------------------------------------------------------------------------- Rows to JSON -- Go from a set of "rows" returned by db.Query to a JSON string. ------------------------------------------------------------------------------------------------- :pgx:func RowsToJsonFirstRow(rows *pgx.Rows) (string, string) {

func Run1

func Run1(db *sql.DB, q string, arg ...interface{}) error

------------------------------------------------------------------------------------------------- test: t-run1q.go, .sql, .out ------------------------------------------------------------------------------------------------- :pgx:func Run1(db *pgx.Conn, q string, arg ...interface{}) error {

func Run1IdThx

func Run1IdThx(db *sql.DB, trx *tr.Trx, q string, data ...interface{}) (err error, id string)

func Run1Thx

func Run1Thx(db *sql.DB, trx *tr.Trx, q string, data ...interface{}) error

func Run2

func Run2(db *sql.DB, q string, arg ...interface{}) (nr int64, err error)

:pgx:func Run2(db *pgx.Conn, q string, arg ...interface{}) (nr int64, err error) { :pgx: nr = 0 :pgx: err = nil :pgx: :pgx: h := HashStr.HashStrToName(q) + q :pgx: :pgx: //tr.TraceDb2 ( "Run1", q, arg... ) :pgx: ps, err := db.Prepare(h, q) :pgx: if err != nil { :pgx: //tr.TraceDbError2 ( "Run1.(Prepare)", q, err ) :pgx: return :pgx: } :pgx: _ = ps :pgx: :pgx: // R, err := stmt.Exec(h, arg...) :pgx: R, err := db.Exec(h, arg...) :pgx: if err != nil { :pgx: //tr.TraceDbError2 ( "Run1.(Exec)", q, err ) :pgx: return :pgx: } :pgx: :pgx: //nr, err = R.RowsAffected() :pgx: //if err != nil { :pgx: // //tr.TraceDbError2 ( "Run1.(Exec)", q, err ) :pgx: // return :pgx: //} :pgx: nr = R.RowsAffected() :pgx: :pgx: //tr.TraceDbEnd ( "Run1.(*Success*)", q, 0 ) :pgx: return :pgx:}

func SVar

func SVar(v interface{}) string

SVar convert a variable to it's JSON representation and return

func SVarI

func SVarI(v interface{}) string

SVarI convert a variable to it's JSON representation with indendted JSON

func SearchPath

func SearchPath(rawFileName string, searchPath string) (fullFileName string, ok bool)

func SearchPathApp

func SearchPathApp(rawFileName string, appName string, searchPath string) (fullFileName string, ok bool)

Perform a search for files and return the full name for each file.

rawFileName: sql-cfg.json appName: "store"

func SearchPathAppModule

func SearchPathAppModule(rawFileName string, appName string, searchPath []string) (fullFileName []string, ok bool)

func SelData

func SelData(db *sql.DB, q string, data ...interface{}) []map[string]interface{}

SelData seelct data from the database and return it. :pgx:func SelData(db *pgx.Conn, q string, data ...interface{}) []map[string]interface{} {

func SelData2

func SelData2(db *sql.DB, q string, data ...interface{}) ([]map[string]interface{}, error)

------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------- :pgx:func SelData2(db *pgx.Conn, q string, data ...interface{}) ([]map[string]interface{}, error) {

func SelDataTrx

func SelDataTrx(db *sql.DB, trx *tr.Trx, q string, data ...interface{}) []map[string]interface{}

------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------- :pgx:func SelDataTrx(db *pgx.Conn, trx *tr.Trx, q string, data ...interface{}) []map[string]interface{} {

func SelQ

func SelQ(db *sql.DB, q string, data ...interface{}) (Rows *sql.Rows, err error)

------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------- :pgx:func SelQ(db *pgx.Conn, q string, data ...interface{}) (Rows *pgx.Rows, err error) {

func SlugToUUID

func SlugToUUID(slug string) (uuid string)

func SubstitueUserInFilePath

func SubstitueUserInFilePath(s string, mdata map[string]string) (rs string, has bool)

func SubstitueUserInFilePathImmediate

func SubstitueUserInFilePathImmediate(s string) (rs string)

func TypeOf

func TypeOf(v []interface{})

------------------------------------------------------------------------------------------------

func URIToStringMap

func URIToStringMap(req *http.Request) (m url.Values, fr map[string]string)

func UUIDAsStr

func UUIDAsStr() (s_id string)

func UUIDAsStrPacked

func UUIDAsStrPacked() (s_id string)

func UUIDToSlug

func UUIDToSlug(uuid string) (slug string)

func XVar

func XVar(v interface{}) string

XVar convert a variable to it's XML representation

func XVarI

func XVarI(v interface{}) string

XVarI convert a variable ot it's XML representaiton with indented XML

Types

type MyDb

type MyDb struct {
	//:pgx: Db     *pgx.Conn
	Db     *sql.DB
	DbType string
}

func ConnectToAnyDb

func ConnectToAnyDb(db_type string, auth string, dbName string) *MyDb

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL