stringz

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToSlice

func MapToSlice(m map[string]struct{}) []string

MapToSlice converts a map to slice.

func Ptr

func Ptr(v string) *string

Ptr returns a pointer to the value.

func PtrDefToNil

func PtrDefToNil(v string, def string) *string

PtrDefToNil returns a pointer to the value, or nil if "def".

func PtrZeroToNil

func PtrZeroToNil(v string) *string

PtrZeroToNil returns a pointer to the value, or nil if "".

func SafeIndex

func SafeIndex(s []string, i int) string

SafeIndex returns "s[i]" if possible, and 0 otherwise.

func SafeIndexDef

func SafeIndexDef(s []string, i int, def string) string

SafeIndexDef returns "s[i]" if possible, and "def" otherwise.

func SafeIndexPtr

func SafeIndexPtr(s []string, i int) *string

SafeIndexPtr returns "s[i]" if possible, and nil otherwise.

func SliceToMap

func SliceToMap(s []string) map[string]struct{}

SliceToMap converts a slice to map.

func Val

func Val(v *string) string

Val returns the pointer value, defaulting to "" if nil.

func ValDef

func ValDef(v *string, def string) string

ValDef returns the pointer value, defaulting to "def" if nil.

Types

type Slice

type Slice []string

Slice is a slice of values.

func (Slice) Len

func (s Slice) Len() int

Len implements the sort.Interface interface.

func (Slice) Less

func (s Slice) Less(i, j int) bool

Less implements the sort.Interface interface.

func (Slice) Swap

func (s Slice) Swap(i, j int)

Swap implements the sort.Interface interface.

Jump to

Keyboard shortcuts

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