utils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2021 License: MIT Imports: 8 Imported by: 0

README

utils-go

pkg goreportcard workflow codecov

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrShouldNotBeNil should not be nil
	ErrShouldNotBeNil = errors.New("should not be nil")

	// ErrStringIsEmpty string is empty
	ErrStringIsEmpty = errors.New("string is empty")

	// ErrSliceIsNil slice is nil
	ErrSliceIsNil = errors.New("slice is nil")

	// ErrEnvironmentVariableIsNotSetOrEmpty environment variable is not set or empty
	ErrEnvironmentVariableIsNotSetOrEmpty = errors.New("environment variable is not set or empty")
)

Functions

This section is empty.

Types

type EnvUtils

type EnvUtils struct{}

EnvUtils is an empty structure that is prepared only for creating methods.

var Env *EnvUtils

Env is an entity that allows the methods of EnvUtils to be executed from outside the package without initializing EnvUtils.

func (*EnvUtils) GetBool

func (*EnvUtils) GetBool(env string) (value bool, err error)

GetBool returns the value of the environment variable `env` if it is set, or the error if it is not set or invalid.

func (*EnvUtils) GetInt

func (*EnvUtils) GetInt(env string) (value int, err error)

GetInt returns the value of the environment variable `env` if it is set, or the error if it is not set or invalid.

func (*EnvUtils) GetOrDefaultBool

func (*EnvUtils) GetOrDefaultBool(env string, defaultValue bool) (value bool)

GetOrDefaultBool returns the value of the environment variable `env` if it is set, or `defaultValue` if it is not set.

func (*EnvUtils) GetOrDefaultInt

func (*EnvUtils) GetOrDefaultInt(env string, defaultValue int) (value int)

GetOrDefaultInt returns the value of the environment variable `env` if it is set, or `defaultValue` if it is not set.

func (*EnvUtils) GetOrDefaultSecond

func (*EnvUtils) GetOrDefaultSecond(env string, defaultValue time.Duration) (value time.Duration)

GetOrDefaultSecond returns the value of the environment variable `env` if it is set, or `defaultValue` if it is not set.

func (*EnvUtils) GetOrDefaultString

func (*EnvUtils) GetOrDefaultString(env, defaultValue string) (value string)

GetOrDefaultString returns the value of the environment variable `env` if it is set, or `defaultValue` if it is not set.

func (*EnvUtils) GetSecond

func (*EnvUtils) GetSecond(env string) (value time.Duration, err error)

GetSecond returns the value of the environment variable `env` if it is set, or the error if it is not set or invalid.

func (*EnvUtils) GetString

func (*EnvUtils) GetString(env string) (value string, err error)

GetString returns the value of the environment variable `env` if it is set, or the error if it is not set.

type MIMEUtils

type MIMEUtils struct{}

MIMEUtils is an empty structure that is prepared only for creating methods.

var MIME *MIMEUtils

MIME is an entity that allows the methods of MIMEUtils to be executed from outside the package without initializing MIMEUtils.

func (*MIMEUtils) DetectContentType

func (*MIMEUtils) DetectContentType(reader io.Reader) (contentType string, err error)

DetectContentType is equivalent to http.DetectContentType and uses io.Reader, so it saves memory.

type SliceUtils

type SliceUtils struct{}

SliceUtils is an empty structure that is prepared only for creating methods.

var Slice *SliceUtils

Slice is an entity that allows the methods of SliceUtils to be executed from outside the package without initializing SliceUtils.

func (*SliceUtils) ContainsInt

func (*SliceUtils) ContainsInt(slice []int, value int) bool

ContainsInt returns whether or not the passed slice contains the passed value.

func (*SliceUtils) ContainsString

func (*SliceUtils) ContainsString(slice []string, value string) bool

ContainsString returns whether or not the passed slice contains the passed value.

Jump to

Keyboard shortcuts

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