Documentation
¶
Overview ¶
Package go_common_lib is a simple Go module used as smaple module for most popular func.
See README.md for more info.
Index ¶
- Variables
- func CalcHash(aStr string) string
- func CheckStingSliceContain(ctx context.Context, slice []string, item string) bool
- func ConvertInterfaceToSliceMapString(ctx context.Context, in interface{}) ([]map[string]string, error)
- func ConvertInterfaceToSliceString(ctx context.Context, t interface{}) ([]string, error)
- func DecodeInterfaceToInterface(ctx context.Context, data interface{}, out interface{}) error
- func GetStringHash(ctx context.Context, aStr string) string
- func ListConvert(in interface{}) ([]string, error)
- func MapListConvert(in interface{}) ([]map[string]string, error)
- func SliceContain(slice []string, item string) bool
- func SortedMap(m []map[string]string) (out []map[string]string)
- func SortedSliceMapString(ctx context.Context, m []map[string]string) []map[string]string
- func SpanSetAttribute(sp trace.Span, prefix string, attributs interface{})
- func StandardizeSpaces(s string) string
- func StringFromList(list []string) (st string)
- func StringFromStingSlice(ctx context.Context, list []string) (st string)
- func TrimString(ctx context.Context, s string) string
- func UpdateList(slice []string, item string) []string
- func UpdateListBySplit(slice []string, item string, spliters []string) []string
- func UpdateMapList(sliceMaps []map[string]string, itemMap map[string]string) []map[string]string
- func UpdateSliceMapStringFromMapString(ctx context.Context, sliceMaps []map[string]string, itemMap map[string]string) []map[string]string
- func UpdateStingSlice(ctx context.Context, slice []string, item string) []string
- func UpdateStingSliceBySplit(ctx context.Context, slice []string, item string, spliters []string) []string
- func UpdateStingSliceFromStingSlice(ctx context.Context, main []string, in []string) []string
- func UpdateStructList(main []string, in []string) []string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
Log = logging.Log
)
Functions ¶
func CalcHash ¶
A function for calculate string hash sum by sha256 The return value is hash string
Example ¶
Example generate hash string for string data
result := CalcHash("testString") fmt.Println("Hash:", result)
Output: Hash: 4acf0b39d9c4766709a3689f553ac01ab550545ffa4544dfc0b2cea82fba02a3
func CheckStingSliceContain ¶ added in v1.0.5
A function to check slice contain item string The return value is bool
func ConvertInterfaceToSliceMapString ¶ added in v1.0.4
func ConvertInterfaceToSliceMapString(ctx context.Context, in interface{}) ([]map[string]string, error)
A function for convert interface to slice map The return value is slice map or error
func ConvertInterfaceToSliceString ¶ added in v1.0.4
A function for convert interface to slice strings The return value is slice strings
func DecodeInterfaceToInterface ¶ added in v1.0.4
A function for decode one interface values to anothe The return set multi atributes to span
func GetStringHash ¶ added in v1.0.4
A function for calculate string hash sum by sha256 The return value is hash string
func ListConvert ¶
A function for convert interface to slice strings The return value is slice strings
Example ¶
Example convert interface to slice strings
var in interface{} in = []string{"first", "second"} result, _ := ListConvert(in) fmt.Println("Slice:", result)
Output: Slice: [first second]
func MapListConvert ¶
A function for convert interface to slice map The return value is slice map or error
Example ¶
Example convert slice map string to string
var names interface{} names = []map[string]string{{"first": "second"}} result, _ := MapListConvert(names) fmt.Println("String:", result)
Output: String: [map[first:second]]
func SliceContain ¶
A function to check slice contain item string The return value is bool
Example ¶
Example check slice contain value
result := SliceContain([]string{"a", "b", "c"}, "b") fmt.Println("Contain:", result)
Output: Contain: true
func SortedMap ¶
A function for sort slice map`s The return value is sorted slice
Example ¶
Example sort slice map string by key
result := SortedMap([]map[string]string{{"b": "c", "c": "c", "a": "c"}}) fmt.Println("Sorted map:", result)
Output: Sorted map: [map[a:c] map[b:c] map[c:c]]
func SortedSliceMapString ¶ added in v1.0.4
A function for sort slice map`s The return value is sorted slice
func SpanSetAttribute ¶ added in v1.0.4
A function for set multi atributes to span The return set multi atributes to span
func StandardizeSpaces ¶
A function for trim first & last space The return value is trimed string
Example ¶
Example strip first and last spaces
result := StandardizeSpaces(" ggg ggg ggg ") fmt.Println("String:", result)
Output: String: ggg ggg ggg
func StringFromList ¶
A function convert slice to sting The return value is string
Example ¶
Example convert slice to string
result := StringFromList([]string{"a", "b", "c"}) fmt.Println("String:", result)
Output: String: a,b,c
func StringFromStingSlice ¶ added in v1.0.5
A function convert slice to sting The return value is string
func TrimString ¶ added in v1.0.5
A function for trim first & last space The return value is trimed string
func UpdateList ¶
A function for update exist slice not contain item string The return value is new slice
Example ¶
Example update string slice add new value if not contain
result := UpdateList([]string{"a", "b", "c"}, "d") fmt.Println("New slice:", result)
Output: New slice: [a b c d]
func UpdateListBySplit ¶
A function for update slice string by splited values use slice spliters string The return value is slice strings
Example ¶
Example update slice string values by splited data
result := UpdateListBySplit([]string{"A", "B"}, "B*C", []string{"*"}) fmt.Println("String:", result)
Output: String: [A B C]
func UpdateMapList ¶
A function for update slince map by not exist map The return value is updated slice
Example ¶
Example update map string slice by anothe add new data or value
result := UpdateMapList([]map[string]string{{"a": "b"}}, map[string]string{"b": "b"}) fmt.Println("Slice:", result)
Output: Slice: [map[a:b] map[b:b]]
func UpdateSliceMapStringFromMapString ¶ added in v1.0.4
func UpdateSliceMapStringFromMapString(ctx context.Context, sliceMaps []map[string]string, itemMap map[string]string) []map[string]string
A function for update slince map by not exist map The return value is updated slice
func UpdateStingSlice ¶ added in v1.0.4
A function for update exist slice not contain item string The return value is new slice
func UpdateStingSliceBySplit ¶ added in v1.0.5
func UpdateStingSliceBySplit(ctx context.Context, slice []string, item string, spliters []string) []string
A function for update slice string by splited values use slice spliters string The return value is slice strings
func UpdateStingSliceFromStingSlice ¶ added in v1.0.4
A function for update exist slice values from anothe slice The return value is updated slice
func UpdateStructList ¶
A function for update exist slice values from anothe slice The return value is updated slice
Example ¶
Example update string slice by anothe string slice add not contain datas
result := UpdateStructList([]string{"a", "b"}, []string{"a", "c"}) fmt.Println("Updated slice:", result)
Output: Updated slice: [a b c]
Types ¶
This section is empty.