utils

package module
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: MIT Imports: 20 Imported by: 15

README

Utils

Various utility functions

Array Functions

  • ArrayContains(array interface{}, val interface{}) (exists bool, index int)
  • IsStringArrayEqual(a, b []string) bool

Email Functions

  • EmailSend(from string, to []string, subject string, htmlMessage string) (bool, error)

Environment Variables Functions

  • AppAddress() string
  • AppEnv() string
  • AppName() string
  • AppPort() string
  • AppURL() string
  • DbDriver() string
  • DbHost() string
  • DbPort() string
  • DbDatabase() string
  • DbUsername() string
  • DbPassword() string
  • EmailFromAddress() string
  • EmailFromName() string
  • Env(key string) string

Fiber Framework Functions

  • FiberAllIps(c *fiber.Ctx) []string
  • FiberGetValueArray2D(c *fiber.Ctx, key string, defaultValue ...[]string)

File Functions

  • FileExists(filePath string) bool
  • FileGetContents(filename string) (string, error)

Interface FUnctions

  • InterfaceToStringArray(v interface{}) []string
  • LinkWebsite() string

Map Functions

  • MapToColumn(inputMap []map[string]string, keyName string) []string
  • MapToKeyValue(inputMap []map[string]string, keyName string, valueName string) map[string]string

String Functions

  • TemplateParseString(template string, data) string

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppAddress added in v1.2.1

func AppAddress() string

AppAddress return the full URL and PORT for the app

func AppEnv added in v1.2.1

func AppEnv() string

AppEnv returns the environment the app is running in

func AppName added in v1.2.1

func AppName() string

AppName return the name for the app

func AppPort added in v1.2.1

func AppPort() string

AppPort return the port for the app

func AppURL added in v1.2.1

func AppURL() string

AppURL return the URL for the app

func ArrayContains added in v1.3.7

func ArrayContains(array interface{}, val interface{}) (exists bool, index int)

ArrayContains checks whether an array contains the specified value

func DbDatabase added in v1.2.2

func DbDatabase() string

DbDatabase return the name of the database

func DbDriver added in v1.2.2

func DbDriver() string

DbDriver returns the driver of the database

func DbHost added in v1.2.2

func DbHost() string

DbHost return the host of the database

func DbPassword added in v1.2.2

func DbPassword() string

DbPassword return the password for the database

func DbPort added in v1.2.2

func DbPort() string

DbPort return the port of the database

func DbUsername added in v1.2.2

func DbUsername() string

DbUsername return the username of the database

func EmailFromAddress added in v1.2.1

func EmailFromAddress() string

EmailFromAddress return the URL for the app

func EmailFromName added in v1.2.1

func EmailFromName() string

EmailFromName return the URL for the app

func EmailSend added in v1.3.5

func EmailSend(from string, to []string, subject string, htmlMessage string) (bool, error)

EmailSend sends an email

func Env added in v1.2.1

func Env(key string) string

Env returns the value for an environment key

func FiberAllIps added in v1.3.7

func FiberAllIps(c *fiber.Ctx) []string

FiberAllIps returns all the IPs in the chain

func FiberGetValueArray2D added in v1.1.2

func FiberGetValueArray2D(c *fiber.Ctx, key string, defaultValue ...[]string) [][]string

FiberGetValueArray2D return a 2D array of a post body Defaults to nil if the form key doesn't exist. If a default value is given, it will return that value if the form key does not exist. Returned value is only valid within the handler. Do not store any references. Make copies or use the Immutable setting instead.

func FileExists added in v1.2.4

func FileExists(filePath string) bool

FileExists checks if a file exists

func FileGetContents added in v1.2.4

func FileGetContents(filename string) (string, error)

FileGetContents reads entire file into a string

func InterfaceToStringArray added in v1.4.1

func InterfaceToStringArray(v interface{}) []string

InterfaceToStringArray converts an interface to String array

func IsNumeric added in v1.3.5

func IsNumeric(s string) bool

IsNumeric checks if a string is numeric

func IsStringArrayEqual added in v1.4.1

func IsStringArrayEqual(a, b []string) bool

IsStringArrayEqual checks whether 2 string arrays are the same

func LinkWebsite added in v1.3.1

func LinkWebsite() string

LinkWebsite returns a URL to the current website

func MapToColumn added in v1.3.2

func MapToColumn(inputMap []map[string]string, keyName string) []string

MapToColumn Returns a column from map

func MapToKeyValue added in v1.3.2

func MapToKeyValue(inputMap []map[string]string, keyName string, valueName string) map[string]string

MapToKeyValue Returns a column from map

func RandStr added in v1.3.4

func RandStr(len int) string

RandStr generates random string of specified length

func Req added in v1.3.5

func Req(r *http.Request, key string, defaultValue string) string

Req returns a POST or GET variable, or default if not exists

func Respond added in v1.3.5

func Respond(w http.ResponseWriter, response api.Response)

Respond returns an API response as JSON

func Slugify added in v1.3.2

func Slugify(s string, replaceWith rune) string

Slugify replaces each run of characters which are not ASCII letters or numbers with the Replacement character, except for leading or trailing runs. Letters will be stripped of diacritical marks and lowercased. Letter or number codepoints that do not have combining marks or a lower-cased variant will be passed through unaltered.

func TemplateParseString

func TemplateParseString(templateString string, data interface{}) string

TemplateParseString parses a template string with the passed data

Types

This section is empty.

Jump to

Keyboard shortcuts

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