utils

package
v0.0.0-...-b87fc4c Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(path_ string) (bool, error)

FileExists checks if that the file exists

func LoadJsonFile

func LoadJsonFile(filePath string) (map[string]interface{}, error)

load json file to a map

func MapToStruct

func MapToStruct(m map[string]interface{}, s interface{})

convert map to struct

func NamedRegexpGroup

func NamedRegexpGroup(str string, reg *regexp.Regexp) (ng map[string]string, matched bool)

match regexp with string, and return a named group map Example:

regexp: "(?P<name>[A-Za-z]+)-(?P<age>\\d+)"
string: "CGC-30"
return: map[string]string{ "name":"CGC", "age":"30" }

func SnakeCasedName

func SnakeCasedName(name string) string

convert like this: "HelloWorld" to "hello_world"

func StructName

func StructName(s interface{}) string

StructName gets the Struct's name

func StructToMap

func StructToMap(s interface{}) map[string]interface{}

convert struct to map

func StructToSnakeKeyMap

func StructToSnakeKeyMap(s interface{}) map[string]interface{}

convert struct to map but struct's field name to snake cased map key

Types

This section is empty.

Jump to

Keyboard shortcuts

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