utils

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirMode  = 0755
	DefaultFileMode = 0644
)

Variables

This section is empty.

Functions

func BoolPtr added in v0.9.5

func BoolPtr(bl bool) *bool

BoolPtr returns the pointer to bool variable

func CheckResource added in v0.9.6

func CheckResource(r *common.Resources) error

func CreateDirIfNotExist

func CreateDirIfNotExist(dirpath string) error

func CreateOrOverwriteFile

func CreateOrOverwriteFile(fpath string, data []byte, fileMode os.FileMode) error

func GenCallerID

func GenCallerID() string

timestamp + uuid

func GenClientTLSConfig

func GenClientTLSConfig(caFile string, certFile string, keyFile string) (*tls.Config, error)

GenClientTLSConfig creates the tls Config for client

func GenConfigFileID added in v0.9.6

func GenConfigFileID(prefix string, configFileName string, version int64) string

func GenMD5

func GenMD5(content string) string

func GenRequestUUID

func GenRequestUUID() string

func GenServerTLSConfigFromCAFile

func GenServerTLSConfigFromCAFile(caFile string) (*tls.Config, error)

GenServerTLSConfigFromCAFile creates a tls Config with ClientCAs.

func GenServerTLSConfigWithCA

func GenServerTLSConfigWithCA(clientCACert []byte) (*tls.Config, error)

GenServerTLSConfigWithCA creates a tls Config with ClientCAs.

func GenServiceMemberName

func GenServiceMemberName(serviceName string, index int64) string

func GenUUID

func GenUUID() string

GenUUID returns a 32 bytes uuid string

func GetConfigFileVersion

func GetConfigFileVersion(fileID string) (version int64, err error)

func GetNextIP added in v0.8.1

func GetNextIP(usedIPs map[string]bool, ipnet *net.IPNet, lastIP net.IP) (nextIP net.IP, err error)

GetNextIP gets the next unused ip. aws reserves like 10.0.0.0, 10.0.0.1, 10.0.0.2, 10.0.0.3 and 10.0.0.255, http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html

func GetReqIDFromContext

func GetReqIDFromContext(ctx context.Context) string

GetReqIDFromContext gets the requuid from ctx.

func Hash

func Hash(s string) uint32

func Int32Ptr added in v0.9.5

func Int32Ptr(i int32) *int32

Int32Ptr returns the pointer to int32 variable

func Int64Ptr added in v0.9.5

func Int64Ptr(i int64) *int64

Int64Ptr returns the pointer to int64 variable

func IsDirExist

func IsDirExist(dirpath string) (bool, error)

func IsFileExist

func IsFileExist(fpath string) (bool, error)

func NewRequestContext

func NewRequestContext(ctx context.Context, requuid string) context.Context

NewRequestContext returns a new Context carrying requuid.

func SetLogDir

func SetLogDir()

func SetLogToStd

func SetLogToStd()

Types

This section is empty.

Jump to

Keyboard shortcuts

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