modulepackage
0.0.0-20171031201240-5db483fbbe25
Repository: https://github.com/czarsimon/util.git
Documentation: pkg.go.dev
# README
util
Utility package for go
go get github.com/CzarSimon/util
# Functions
BytesToFloatSlice Turnas slice of bytes to a slice of ints of a users specified size.
BytesToIntSlice turns a slice of bytes to a slice of ints of a user specified size.
BytesToStrSlice turns a byte array into a string array.
CheckErr logs an error if present.
CheckErrAndRollback check and error and if present logs the error andperforms a rollback on the supplied transactoin.
CheckErrFatal logs an error if present and if so also exits.
onnectPG Ceates a connection to a postgresql DB, exits if there is an error.
ConnectPGErr Creates a connection to a postgres DB, returns an error if failed.
DecodeJSON Decodes json into a reciving variable.
FileExists checks if a file identified by a supplied path exist.
GetEnvVar gets an envrionment variable based on a key, returns a default valueif the environment variable is not found.
GetPGConfig creates a PGConfig based on environment variables and default values.
GetSQLiteConfig creates a SQLiteConfig based on the parameter filename.
IsErr checks if an error is not nil.
IsWeekend Checks if the currenct day (timezone UTC) is a weekend day.
LogErr logs the supplied error to the console.
ParseValueFromQuery Parses a query value from request.
PgArrayToString turns a byte arra into a string without enclosing {}.
Ping sends a 200 response if the server is running.
PlaceholderHandler is a dummy handler to ease development.
PrintErr Prints the supplied error to stdout.
SendErrRes sends a given error to the requestor.
SendErrStatus Sends an error and a given status code to the requestor.
SendJSONRes send a given JSON respons to the requestor.
SendJSONStringRes serializes a given message sting to JSON and sends to the requestor.
SendOK sends status code 200 to the requestor.
SendPlainTextRes sends a plain text message given as an input.
SendUnauthorized Sends an unauthorized status to the requestor.
# Structs
EnvVar Key value pair for an enviornment variable.
JSONRes contains a response.
PGConfig holds connection parameters for a postgresql db.
ServerConfig contains setup and connection info for a server.
SQLiteConfig holds connection parameters for a SQLlite database.