Documentation ¶
Index ¶
- Constants
- Variables
- func BasePath(base, api string) string
- func CamelCaseToSnakeCase(s string) string
- func CastFloat(val interface{}) (float64, error)
- func CastInt(val interface{}) (int, error)
- func CastInt64(val interface{}) (int64, error)
- func CastString(val interface{}) (string, error)
- func CheckEntries(list1, list2 []string) bool
- func Color(col, text string) string
- func ColorURL(rurl string) string
- func ConvertCamelCaseKeys(rec map[string]any) map[string]any
- func ConvertFloat(val string) string
- func CreateDID(rec map[string]any, attrs, sep, div string) string
- func DIDKeys(attrs string) []string
- func Domain() string
- func Equal[T ListEntry](a, b []T) bool
- func EqualLists(list1, list2 []string) bool
- func ErrPropagate(api string)
- func ErrPropagate2Channel(api string, ch chan interface{})
- func Error(args ...interface{})
- func Expire(expire int) int64
- func FileName(fname string) string
- func FindFiles(root string) []string
- func FindInList(a string, arr []string) bool
- func FullPath(fname string) string
- func GetDid(rec map[string]any) string
- func GetEnv(key string) string
- func GetHash(data []byte) string
- func GoDeferFunc(api string, f func())
- func HttpClient() *http.Client
- func HttpGet(rurl string, headers map[string]string) (*http.Response, error)
- func HttpPost(rurl string, headers map[string]string, buffer *bytes.Buffer) (*http.Response, error)
- func HttpPostForm(rurl string, headers map[string]string, formData url.Values) (*http.Response, error)
- func InList[T ListEntry](a T, list []T) bool
- func Insert(arr []interface{}, val interface{}) []interface{}
- func IsFloat(val string) bool
- func IsInt(val string) bool
- func List2Set[T ListEntry](arr []T) []T
- func ListFiles(dir string) []string
- func MapIntKeys(rec map[int]interface{}) []int
- func MapKeys(rec map[string]interface{}) []string
- func Max(data []interface{}) float64
- func Min(data []interface{}) float64
- func OrderedSet[T ListEntry](list []T) []T
- func PaddedKey(key string, maxLen int) string
- func PrintSQL(stm string, args []interface{}, msg string)
- func RandomString() string
- func ReadToken(r string) string
- func RecordSize(v interface{}) (int64, error)
- func ReplaceBinds(stm string) string
- func Response(rurl string, data []byte) []byte
- func Set[T ListEntry](arr []T) []T
- func SizeFormat(val interface{}) string
- func Stack() string
- func Sum(data []interface{}) float64
- func TimeFormat(ts interface{}) string
- func UniqueFormValues(vals []string) []string
- func Unix2Time(ts int64) string
- func UnixTime(ts string) int64
- func UpdateOrderedDict(omap, nmap map[int][]string) map[int][]string
- func Warning(args ...interface{})
- type DevNullWriter
- type GzipReader
- type GzipWriter
- type Int64List
- type IntList
- type ListEntry
- type ResponseType
- type StdoutWriter
- type StringList
Constants ¶
const BLACK = "0;30m"
BLACK color
const BLUE = "0;34m"
BLUE color
const BOLD = "\x1b[1m"
BOLD type
const BROWN = "0;33m"
BROWN color
const CYAN = "0;36m"
CYAN color
const GREEN = "0;32m"
GREEN color
const LIGHT_CYAN = "1;36m"
LIGHT_CYAN color
const LIGHT_PURPLE = "1;35m"
LIGHT_PURPLE color
const PLAIN = "\x1b[0m"
PLAIN type
const PURPLE = "0;35m"
PURPLE color
const RED = "0;31m"
RED color
Variables ¶
var PatternDataset = regexp.MustCompile("/[-a-zA-Z_0-9*]+/[-a-zA-Z_0-9*]+/[-a-zA-Z_0-9*]+")
PatternDataset represents CHESS dataset
var PatternFile = regexp.MustCompile("/[a-zA-Z_0-9].*\\.root$")
PatternFile represents CHESS file
var PatternFloat = regexp.MustCompile("[+-]?([0-9]*[.])?[0-9]+")
PatternFloat represents an integer pattern
var PatternInt = regexp.MustCompile("(^[0-9-]$|^[0-9-][0-9]*$)")
PatternInt represents an integer pattern
var PatternRun = regexp.MustCompile("[0-9]+")
PatternRun represents CHESS run
var PatternURL = regexp.MustCompile("(https|http)://[-A-Za-z0-9_+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]")
PatternURL represents URL pattern
var TIMEOUT int
TIMEOUT defines timeout for net/url request
var UrlCounter uint32
UrlCounter for profile output
var VERBOSE int
VERBOSE defines verbosity level
var Verbose int
Verbose controls verbosity level of function printouts
Functions ¶
func CamelCaseToSnakeCase ¶ added in v0.2.3
CamelCaseToSnakeCase converts CamelCase string object to `camel_case`, code generated by ChatGPT, but further adjusted to accommodate special cases, like CESRConditions => cesr_conditions
func CastString ¶
CastString function to check and cast interface{} to string data-type
func CheckEntries ¶
CheckEntries helper function to check that entries from list1 are all appear in list2
func Color ¶
Color prints given string in color based on ANSI escape codes, see http://www.wikiwand.com/en/ANSI_escape_code#/Colors
func ConvertCamelCaseKeys ¶ added in v0.2.3
ConvertCacmeCaseKeys converts map with CamelCase keys to map with snake case keys
func ConvertFloat ¶
ConvertFloat converts string representation of float scientific number to string int
func DIDKeys ¶ added in v0.1.6
DIDKeys provide sorted, lower-case list of did keys from comma separated list of attributes
func Equal ¶
Equal tells whether a and b contain the same elements. A nil argument is equivalent to an empty slice.
func EqualLists ¶
EqualLists helper function to compare list of strings
func ErrPropagate ¶
func ErrPropagate(api string)
ErrPropagate helper function which can be used in defer ErrPropagate()
func ErrPropagate2Channel ¶
func ErrPropagate2Channel(api string, ch chan interface{})
ErrPropagate2Channel helper function which can be used in goroutines as ch := make(chan interface{})
go func() { defer ErrPropagate2Channel(api, ch) someFunction() }()
func FindInList ¶
FindInList helper function to find item in a list
func GoDeferFunc ¶
func GoDeferFunc(api string, f func())
GoDeferFunc runs any given function in defered go routine
func HttpPostForm ¶
func HttpPostForm(rurl string, headers map[string]string, formData url.Values) (*http.Response, error)
HttpPostForm performs HTTP POST form request with bearer token
func Insert ¶
func Insert(arr []interface{}, val interface{}) []interface{}
Insert inserts value into array at zero position
func List2Set ¶
func List2Set[T ListEntry](arr []T) []T
List2Set helper function to convert input list into set
func MapIntKeys ¶
MapIntKeys returns int keys from a map
func Max ¶
func Max(data []interface{}) float64
Max helper function to perform Max operation over provided array of values
func Min ¶
func Min(data []interface{}) float64
Min helper function to perform Min operation over provided array of values
func RecordSize ¶
RecordSize returns actual record size of given interface object
func ReplaceBinds ¶
ReplaceBinds replaces given pattern in string
func Response ¶
Response represents final response in a form of JSON structure we use custorm representation
func SizeFormat ¶
func SizeFormat(val interface{}) string
SizeFormat helper function to convert size into human readable form
func Sum ¶
func Sum(data []interface{}) float64
Sum helper function to perform sum operation over provided array of values
func TimeFormat ¶
func TimeFormat(ts interface{}) string
TimeFormat helper function to convert Unix time into human readable form
func UniqueFormValues ¶ added in v0.0.1
UniqueFormValues returns unique list of values from http.Request.FormValue
func UpdateOrderedDict ¶
UpdateOrderedDict returns new ordered list from given ordered dicts
Types ¶
type DevNullWriter ¶
type DevNullWriter string
DevNullWriter provides the same functionality as http.ResponseWriter to cover unit tests of DBS APIs. It prints given data directly to stdout.
func (DevNullWriter) Header ¶
func (s DevNullWriter) Header() http.Header
Header implements Header() API of http.ResponseWriter interface
func (DevNullWriter) Write ¶
func (s DevNullWriter) Write(b []byte) (int, error)
Write implements Write API of http.ResponseWriter interface
func (DevNullWriter) WriteHeader ¶
func (s DevNullWriter) WriteHeader(statusCode int)
WriteHeader implements WriteHeader API of http.ResponseWriter interface
type GzipReader ¶
GzipReader struct to handle GZip'ed content of HTTP requests
type GzipWriter ¶
type GzipWriter struct { GzipWriter *gzip.Writer Writer http.ResponseWriter }
GzipWriter provides the same functionality as http.ResponseWriter It compresses data using compress/zip writer and provides headers from given http.ResponseWriter
func (GzipWriter) Header ¶
func (g GzipWriter) Header() http.Header
Header implements Header() API of http.ResponseWriter interface
func (GzipWriter) Write ¶
func (g GzipWriter) Write(b []byte) (int, error)
Write implements Write API of http.ResponseWriter interface
func (GzipWriter) WriteHeader ¶
func (g GzipWriter) WriteHeader(statusCode int)
WriteHeader implements WriteHeader API of http.ResponseWriter interface
type Int64List ¶
type Int64List []int64
Int64List implement sort for []int type
type IntList ¶
type IntList []int
IntList implement sort for []int type
type ResponseType ¶
type ResponseType struct { Url string // response url Data []byte // response data, i.e. what we got with Body of the response Error error // http error, a non-2xx return code is not an error Status string // http status string StatusCode int // http status code }
ResponseType structure is what we expect to get for our URL call. It contains a request URL, the data chunk and possible error from remote
func FetchResponse ¶
func FetchResponse(rurl string, args []byte) ResponseType
FetchResponse fetches data for provided URL, args is a json dump of arguments
type StdoutWriter ¶
type StdoutWriter string
StdoutWriter provides the same functionality as http.ResponseWriter to cover unit tests of DBS APIs. It prints given data directly to stdout.
func (StdoutWriter) Header ¶
func (s StdoutWriter) Header() http.Header
Header implements Header() API of http.ResponseWriter interface
func (StdoutWriter) Write ¶
func (s StdoutWriter) Write(b []byte) (int, error)
Write implements Write API of http.ResponseWriter interface
func (StdoutWriter) WriteHeader ¶
func (s StdoutWriter) WriteHeader(statusCode int)
WriteHeader implements WriteHeader API of http.ResponseWriter interface
type StringList ¶
type StringList []string
StringList implement sort for []string type
func (StringList) Less ¶
func (s StringList) Less(i, j int) bool
Less implements less function for []int type
func (StringList) Swap ¶
func (s StringList) Swap(i, j int)
Swap implements swap function for []int type