utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthorizationHeader is the header key to get the authorization token
	AuthorizationHeader = "authorization"
	// ESRIAuthorizationHeader is the header key to get the authorization token
	ESRIAuthorizationHeader = "X-Esri-Authorization"
)

Variables

This section is empty.

Functions

func AverageElemF

func AverageElemF(vs []float64) float64

AverageElemF computes the mean value of vs.$ AverageElemF panics if len(vs) = 0

func F64ToS added in v0.3.0

func F64ToS(f float64) string

F64ToS converts float to string using the maximum accuracy

func FindRegexGroups

func FindRegexGroups(reg *regexp.Regexp, v string) (map[string]string, error)

FindRegexGroups returns a map containing the group names as keys and the values matched as values, if the string value matches the regex.

func JoinInt64

func JoinInt64(elems []int64, sep string) string

JoinInt64 is the int64 equivalent of strings.Join

func MakeTemporary

func MakeTemporary(err error) error

func MaxElemF

func MaxElemF(vs []float64) float64

MaxElemF computes the meax value of vs MaxElemF panics if len(vs)=0

func MaxI

func MaxI(a, b int) int

MaxI computes the max value between two integers

func MergeErrors added in v0.3.0

func MergeErrors(priorityToError bool, err error, newErrs ...error) error

MergeErrors, appending texts if priorityToErr is true, priority to the fatal error then to the temporary else, priority to no error, then to the temporary and finally to the fatal error.

func MinElemF

func MinElemF(vs []float64) float64

MinElemF computes the min value of vs. MinElemF panics if len(vs) = 0

func MinI

func MinI(a, b int) int

MinI computes the min value between two integers

func SliceByteToComplex64

func SliceByteToComplex64(b []byte) []complex64

SliceByteToComplex64 converts a slice of byte to a slice of complex64

func SliceByteToFloat32

func SliceByteToFloat32(b []byte) []float32

SliceByteToFloat32 converts a slice of byte to a slice of float32

func SliceByteToFloat64

func SliceByteToFloat64(b []byte) []float64

SliceByteToFloat64 converts a slice of byte to a slice of float34

func SliceByteToInt16

func SliceByteToInt16(b []byte) []int16

SliceByteToInt16 converts a slice of byte to a slice of int16

func SliceByteToInt32

func SliceByteToInt32(b []byte) []int32

SliceByteToInt32 converts a slice of byte to a slice of int32

func SliceByteToInt8

func SliceByteToInt8(b []byte) []int8

SliceByteToInt8 converts a slice of byte to a slice of int8

func SliceByteToUInt16

func SliceByteToUInt16(b []byte) []uint16

SliceByteToUInt16 converts a slice of byte to a slice of uint16

func SliceByteToUInt32

func SliceByteToUInt32(b []byte) []uint32

SliceByteToUInt32 converts a slice of byte to a slice of uint32

func SliceFloat64Equal

func SliceFloat64Equal(a, b []float64) bool

SliceFloat64Equal returns true if the two slices contain the same elements

func SliceInt64Equal

func SliceInt64Equal(a, b []int64) bool

SliceInt64Equal returns true if the two slices contain the same elements

func Temporary

func Temporary(err error) bool

Temporary inspects the error trace and returns whether the error is transient

func ToSliceByte

func ToSliceByte(ptr unsafe.Pointer, l int) []byte

ToSliceByte converts an unsafe.Pointer to a slice of byte Usage: f := []float64{1.0, 2.0, 3.0} b := ToSliceByte(unsafe.Pointer(&f[0]), len(f)*8)

func URLJoin added in v0.3.0

func URLJoin(url string, elems ...string) string

Types

type ErrWaitGroup added in v0.3.0

type ErrWaitGroup struct {
	// contains filtered or unexported fields
}

ErrWaitGroup is a collection of goroutines working on subtasks that are part of the same overall task.

func (*ErrWaitGroup) AppendError added in v0.3.0

func (g *ErrWaitGroup) AppendError(err error)

AppendError to the list of errors

func (*ErrWaitGroup) Go added in v0.3.0

func (g *ErrWaitGroup) Go(f func() error)

Go calls the given function in a new goroutine.

func (*ErrWaitGroup) Wait added in v0.3.0

func (g *ErrWaitGroup) Wait() []error

Wait blocks until all function calls from the Go method have returned, then returns all the non-nil error (if any) from them.

type StringSet

type StringSet map[string]struct{}

StringSet is a set of strings (all elements are unique)

func (StringSet) Exists

func (ss StringSet) Exists(s string) bool

Exists returns true if the string already exists in the Set

func (StringSet) Pop

func (ss StringSet) Pop(s string)

Pop removes the string from the set

func (StringSet) Push

func (ss StringSet) Push(s string)

Push adds the string to the set if not already exists

func (StringSet) Slice

func (ss StringSet) Slice() []string

Slice returns a slice from the set

type TokenAuth

type TokenAuth struct {
	Token string
}

TokenAuth to use with grpc.WithPerRPCCredentials

func (TokenAuth) Authenticate

func (t TokenAuth) Authenticate(token string) error

Authenticate returns nil if token is compliant with TokenAuth else GRPC Error Unauthenticated.

func (TokenAuth) GetRequestMetadata

func (t TokenAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata implements grpc.PerRPCCredentials

func (TokenAuth) RequireTransportSecurity

func (TokenAuth) RequireTransportSecurity() bool

RequireTransportSecurity implements grpc.PerRPCCredentials

Directories

Path Synopsis
Package to handle 2D affine transformations, following GDAL affine convention
Package to handle 2D affine transformations, following GDAL affine convention

Jump to

Keyboard shortcuts

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