Documentation ¶
Index ¶
- Constants
- Variables
- func Assert(tb testing.TB, condition bool, msg string, v ...interface{})
- func CatchShutdown()
- func ConnectBolt(file string) (err error)
- func EnsureNoQueryParameters(r *http.Request) (bool, error)
- func Equals(tb testing.TB, exp, act interface{})
- func GetBuildInfo() (str string, err error)
- func GetQueryParameter(r *http.Request, name string, required bool, defaultOk bool, def string) (string, error)
- func HTML5FormLogin() string
- func HTML5Page(title, content string) string
- func HTML5PageLogin() string
- func HTML5PageNotImplemented(name string) string
- func InitializeBolt(file string) (err error)
- func Ok(tb testing.TB, err error)
- func ReadConfigFile(data interface{}, filename string) (err error)
- func StringArrayContains(arr []string, str string) bool
- func StringToAlphaNumeric(s string) (str string, err error)
- func ValidateDir(filename string) (fullpath string, dirInfo os.FileInfo, err error)
- func ValidateEmailAddress(email string) (err error)
- func ValidateFile(filename string) (fullpath string, fileInfo os.FileInfo, err error)
- func ValidateFileOrParentDir(filename string) (fullpath string, err error)
- type ElementMap
- type ErrList
- type FileDetail
- type Parsed
- type ParsedMap
- type ResultMap
Constants ¶
const (
// MaxIterations Prevents infinite loops
MaxIterations = 100
)
Variables ¶
var ( // DelayShutdown ... DelayShutdown sync.WaitGroup // DelayReason ... DelayReason string )
var BoltDB *bolt.DB
BoltDB global access to BoltDB resource
Functions ¶
func CatchShutdown ¶
func CatchShutdown()
CatchShutdown is a helper function called via goroutine when you start your app the only parameter required is the function you want to call to cleanup your app example: go goutils.CatchShutdown(app.Shutdown())
func ConnectBolt ¶
ConnectBolt given a filename (usually from the config) will open boltDB
func EnsureNoQueryParameters ¶
EnsureNoQueryParameters is a help function for endpoints that require no query parameters
func GetBuildInfo ¶
GetBuildInfo will return git build information as a string. No GOVVV required.
func GetQueryParameter ¶
func GetQueryParameter(r *http.Request, name string, required bool, defaultOk bool, def string) (string, error)
GetQueryParameter is a helper function to get query parameters by name and return error ONLY if they are required and not present and DO NOT have a defined default value.
Example: ``` qpApple,ok := GetQueryParameter(r,"apple",false,true,"Granny Smith")
if err != nil { HandleError(w, http.StatusInternalServerError.RequestURI, err) return }
```
func HTML5FormLogin ¶
func HTML5FormLogin() string
HTML5FormLogin returns string content representing a basic login form centered on the page
func HTML5Page ¶
HTML5Page returns string content representing a valid HTML5 page with the given title set and the content provided placed in a DIV an ID of content
func HTML5PageLogin ¶
func HTML5PageLogin() string
HTML5PageLogin returns a complete basic Login page
func HTML5PageNotImplemented ¶
HTML5PageNotImplemented returns a complete basic
func InitializeBolt ¶
InitializeBolt creates a new BoltDB resource
func ReadConfigFile ¶
ReadConfigFile Read a single config file, return a struct, where 'data' is a pointer to that struct
func StringArrayContains ¶
StringArrayContains helper function to return true or false is a given string exists in the provided string array
func StringToAlphaNumeric ¶
StringToAlphaNumeric given a string will strip all characters except AlphaNumeric and return the result
func ValidateDir ¶
ValidateDir Validate if exists, and is type directory
func ValidateEmailAddress ¶
ValidateEmailAddress tests given email for valid email format
func ValidateFile ¶
ValidateFile Validate if exists, and is type file
func ValidateFileOrParentDir ¶
ValidateFileOrParentDir Validate if exists, and is type file Or parent directory valid, because file is to be created
Types ¶
type ElementMap ¶
type ElementMap map[string]interface{}
ElementMap is the JSON element parsed into a key-value map
type ErrList ¶
type ErrList []string
ErrList Struct to accumulate a list of errors
type FileDetail ¶
FileDetail ...
func DistinctFilenames ¶
func DistinctFilenames(filenames []string, errList *ErrList) (fileDetails []FileDetail)
DistinctFilenames Create Parsed{} struct for each filename, validating and formatting names
type Parsed ¶
type Parsed struct { FileName string DistinctName string Position int ElementMap ElementMap }
Parsed contains each JSON element, remembering where it was found - DistinctName is shortest unique name across all filenames - Position is element # within the file: 0 if single element, 1...N if array of N elements
type ParsedMap ¶
ParsedMap When mutiple files are parsed, a field in each element is specified as the Id - This element Id is used as the ParsedMap key (so becomes a required field)
type ResultMap ¶
type ResultMap map[string]interface{}
ResultMap The Parsed map form is then collapsed into a single data object result per Id
func ReadConfigFiles ¶
func ReadConfigFiles(data interface{}, idName string, filenames ...string) (resultMap ResultMap, err error)
ReadConfigFiles Read a list of config files into a map of structs, where 'data' points to struct and idName is field for map key - Can configure an application using one or more JSON files - For example, put general settings in one file, credentials in a second file.