typeutils

package
v0.0.0-...-fa26ab0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0, BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

Converts a slice of bytes into a string without performing a copy. NOTE: This is an unsafe operation and may lead to problems if the bytes passed as argument are changed while the string is used. No checking whether bytes are valid UTF-8 data is performed.

func IsInterfaceNil

func IsInterfaceNil(param interface{}) bool

Checks whether an interface is nil or has the value nil.

func StringToBytes

func StringToBytes(s string) []byte

Converts a string into a slice of bytes without performing a copy. NOTE: This is an unsafe operation and may lead to problems if the bytes are changed.

Types

type AtomicBool

type AtomicBool int32

AtomicBool is an atomic Boolean Its methods are all atomic, thus safe to be called by multiple goroutines simultaneously Note: When embedding into a struct, one should always use *AtomicBool to avoid copy

func NewAtomicBool

func NewAtomicBool() *AtomicBool

Creates an AtomicBool with default to false

func (*AtomicBool) IsSet

func (ab *AtomicBool) IsSet() bool

IsSet returns whether the Boolean is true

func (*AtomicBool) Set

func (ab *AtomicBool) Set()

Set sets the Boolean to true

func (*AtomicBool) SetTo

func (ab *AtomicBool) SetTo(yes bool)

SetTo sets the boolean with given Boolean

func (*AtomicBool) SetToIf

func (ab *AtomicBool) SetToIf(old, new bool) (set bool)

SetToIf sets the Boolean to new only if the Boolean matches the old Returns whether the set was done

func (*AtomicBool) UnSet

func (ab *AtomicBool) UnSet()

UnSet sets the Boolean to false

Jump to

Keyboard shortcuts

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