utilities

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 6 Imported by: 4

README

Utilites

Go Report Card godoc

Everybody has little functions that the find themselves writing ... and re-writing in different packages. Enough! I got tired of that, so I created a package for it.

You might find them useful, too. Maybe fork a copy and add your own forever-recreated functions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildQuery

func BuildQuery(srcQry string, replacers keyval.KeyVal) (qry string)

BuildQuery replaces the placeholders with values placeholders have the form "?key". BuildQuery prepends a "?" to the keys in replacers.

func FileExists

func FileExists(file string) error

FileExists returns an error if "file" does not exist.

func Has

func Has(needle string, haystack ...string) bool

Has returns true if needle is in haystack

func MaxInt

func MaxInt(ints ...int) int

MaxInt returns the maximum of ints

func MinInt

func MinInt(ints ...int) int

MinInt returns the minimum of ints

func Position

func Position(needle string, haystack ...string) int

Position returns the index of needle in the haystack. It returns -1 if needle is not found. If haystack has length 1, then it is split into a slice with delimiter ",".

func Slash

func Slash(inStr string) string

Slash adds a trailing slash if inStr doesn't end in a slash

func TableExists

func TableExists(table string, conn *chutils.Connect) error

TableExists returns an error if "table" does not exist. conn is the DB connector.

func TempFile

func TempFile(ext string, length int) string

TempFile produces a random temp file name in the system's tmp location. The file has extension "ext". The file name begins with "tmp" has length 3 + length.

func TempTable

func TempTable(tmpDB string, length int) string

TempTable produces a random table name. The table name begins with "tmp". The table's name has length 3 +length. tmpDB is the database name.

func ToFile

func ToFile(fileName, text string) error

ToFile writes string to file fileName, which is created

Types

This section is empty.

Jump to

Keyboard shortcuts

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