shared

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package shared contains common shared information, and utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, v any) error

Decode process stream `r` into `v` and returns an error if any.

func Encode

func Encode(w io.Writer, v any) error

Encode process `v` into stream `w` and returns an error if any.

func GenerateID

func GenerateID(ct string) string

GenerateID generates MD5 hash (content-based) based on content. Good to be used to avoid duplicated messages.

func GenerateUUID

func GenerateUUID() string

GenerateUUID generates a RFC4122 UUID and DCE 1.1: Authentication and Security Services.

func Marshal

func Marshal(v any) ([]byte, error)

Marshal with custom error.

func PrintErrorMessages

func PrintErrorMessages(errors ...error) string

PrintErrorMessages prints the concatenated error messages.

func ReadAll

func ReadAll(r io.Reader) ([]byte, error)

ReadAll reads all the data from `r` and returns an error if any.

func RemoveSpacesAndToLower

func RemoveSpacesAndToLower(s string) string

RemoveSpacesAndToLower removes spaces from the string and converts it to

func SliceContains

func SliceContains(source []string, text string) bool

SliceContains returns true if the slice contains the string.

NOTE: It's case insensitive.

NOTE: @andres moved to here.

func TargetName

func TargetName(name, alternative string) (string, error)

TargetName returns the provided target name, or the configured one. A target, depending on the storage, is a collection, a table, a bucket, etc. For ElasticSearch - as it doesn't have a concept of a database - the target is the index.

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal with custom error.

Types

type N added in v0.0.3

type N interface {
	~int | ~float32 | ~float64 | ~string | bool | ~[]string | ~[]int | []bool | ~[]float32 | ~[]float64 | any
}

N asd

TODO: Make it better.

Jump to

Keyboard shortcuts

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