funks

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 6 Imported by: 9

README

Funks

This library provides useful functions for any GO projects.

Sync

func GetSyncMapSize(m *sync.Map) int

Returns the number of items from the specified sync.Map.

TOML

funks.Duration

Implements the function "UnmarshalText(text []byte) error" from the encoding.TextUnmarshaler interface to parse "time.Duration" from TOML files.

Example:

See funks_test.go for detailed examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHTTPClient

func CreateHTTPClient(timeout time.Duration, insecureSkipVerify bool) *http.Client

CreateHTTPClient - creates a new HTTP client using 0 as maxConnsPerHost

func CreateHTTPClientAdv added in v1.3.1

func CreateHTTPClientAdv(timeout time.Duration, insecureSkipVerify bool, maxConnsPerHost int) *http.Client

CreateHTTPClientAdv - creates a new HTTP client (use zero maxConnsPerHost for unlimited connections)

func GetSyncMapSize

func GetSyncMapSize(m *sync.Map) int

GetSyncMapSize - returns the sync map size

Types

type Duration added in v1.1.0

type Duration struct {
	time.Duration
}

Duration - a duration wrapper type to add the method below

func ForceNewStringDuration added in v1.2.1

func ForceNewStringDuration(value string) *Duration

ForceNewStringDuration - returns a new duration based on a string (panics on error)

func NewDuration added in v1.2.1

func NewDuration(value time.Duration) *Duration

NewDuration - returns a new duration based on duration values

func NewStringDuration added in v1.2.1

func NewStringDuration(value string) (*Duration, error)

NewStringDuration - returns a new duration based on a string

func (*Duration) MarshalJSON added in v1.2.0

func (d *Duration) MarshalJSON() ([]byte, error)

MarshalJSON - transforms the value to the encoded json format

func (*Duration) UnmarshalJSON added in v1.2.0

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON - transforms the json format to the duration format

func (*Duration) UnmarshalText added in v1.1.0

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText - used by the toml parser to proper parse duration values

Jump to

Keyboard shortcuts

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