utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactJSON

func CompactJSON(v interface{}) string

CompactJSON converts v to compact JSON string

func FilePath2Index

func FilePath2Index(in string) (int64, error)

func FilePath2Suffix

func FilePath2Suffix(in string) string

func GetBatchSize

func GetBatchSize(interval float32, fragment int) int

func GetImagePosition

func GetImagePosition(idx int64, rate float32) int64

func GetImageSecond

func GetImageSecond(idx int64, rate float32) float64

func GetMaxFrameLimit

func GetMaxFrameLimit(max int, rate float32) int

func GetRate

func GetRate(interval float32) float32

func GetSegmentStart

func GetSegmentStart(idx int64, seg int) float64

func GetSize

func GetSize(w, h int) string

func If

func If(cond bool, tv, fv interface{}) interface{}

func IndentedJSON

func IndentedJSON(v interface{}) string

IndentedJSON converts v to JSON string with 4-space indent

func IsIPv4 added in v0.1.2

func IsIPv4(v string) bool

IsIPv4 returns whether v is IPv4

func KVStrings2Map added in v0.1.2

func KVStrings2Map(in ...string) map[string]string

KVStrings2Map converts string pairs to map

func LocalIP added in v0.1.2

func LocalIP() (ip net.IP, err error)

LocalIP returns local loopback IP

func LocalIPString added in v0.1.2

func LocalIPString() (ip string, err error)

LocalIPString returns local loopback IP address in string format

func MapKeys

func MapKeys(m map[string]interface{}) []string

MapKeys extracts all keys from given map

func Md5

func Md5(byt []byte) string

func ParseCommaSeparated

func ParseCommaSeparated(in string) []string

ParseCommaSeparated divides the input string seperated by comma (',') into an array

func ReadJSONFromFile added in v0.1.2

func ReadJSONFromFile(file string, v interface{}) error

ReadJSONFromFile reads file content as JSON format, and unmarshalls to pointer v NOTE: v must be a pointer

func ReadJSONResponse added in v0.1.2

func ReadJSONResponse(resp *http.Response, v interface{}) ([]byte, error)

ReadJSONResponse reads HTTP response body, unmarshalls the body to pointer v and returns the JSON bytes array NOTE: v must be a pointer

func Seconds2ClockDuration

func Seconds2ClockDuration(v int64) string

Seconds2ClockDuration converts seconds to clock like duration, e.g. 4003(s) -> 01:06:43

func StartEndOfTheDay added in v0.1.2

func StartEndOfTheDay(t time.Time) (time.Time, time.Time)

StartEndOfTheDay returns start and end time of t's day NOTE: timezone is set to UTC

func StartEndOfTheMonth added in v0.1.2

func StartEndOfTheMonth(t time.Time) (time.Time, time.Time)

StartEndOfTheMonth returns start and end time of t's month NOTE: timezone is set to UTC

func StartEndOfTheYear added in v0.1.2

func StartEndOfTheYear(t time.Time) (time.Time, time.Time)

StartEndOfTheYear returns start and end time of t's year NOTE: timezone is set to UTC

func UnmarshalRawMessage added in v0.1.2

func UnmarshalRawMessage(raw json.RawMessage, v interface{}) error

UnmarshalRawMessage unmarshalls JSON RawMessage to pointer v NOTE: v must be a pointer

func WriteJSONToFile added in v0.1.2

func WriteJSONToFile(v interface{}, file string) error

WriteJSONToFile marshals v and write to file

Types

This section is empty.

Jump to

Keyboard shortcuts

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