Help us shape the future of Go! Take the 2026 Go Developer Survey

parse

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Complex64

func Complex64(s string) (complex64, error)

Complex64 delegates to strconv.ParseComplex for go >= 1.15.

func Complex128

func Complex128(s string) (complex128, error)

Complex128 delegates to strconv.ParseComplex for go >= 1.15.

func Map

func Map(s string, mapType reflect.Type) (reflect.Value, error)

Map converts a string representation of a map with concrete values as keys and vals into a reflect.Value representing that map.

func SignedIntegralSlice added in v0.13.0

func SignedIntegralSlice[I int | int64 | int32 | int16 | int8](s string) ([]I, error)

SignedIntegralSlice splits on commas and parses into a slice of integers Parses with strconv.ParseInt and the base set to 0 so base prefixes are available. Whitespace is trimmed around the integers before parsing to allow for reasonable separtion (shell word-splitting aside)

func String

func String(str string, t reflect.Type) (reflect.Value, error)

String casts the provided string into the provided type, returning the result in a reflect.Value.

func StringSet

func StringSet(s string) (map[string]struct{}, error)

StringSet splits a comma separated string and constructs a map[string]struct{} to represent a set

func StringSlice

func StringSlice(s string) ([]string, error)

StringSlice splits a comma separated string and constructs a slice

func StringStringSliceMap

func StringStringSliceMap(s string) (map[string][]string, error)

StringStringSliceMap takes in a string representation of a map with strings as keys and string slices as values, and converts it to a map[string][]string.

func UnsignedIntegralSlice added in v0.13.0

func UnsignedIntegralSlice[I uint | uint64 | uint32 | uint16 | uint8 | uintptr](s string) ([]I, error)

UnsignedIntegralSlice splits on commas and parses into a slice of integers Parses with strconv.ParseInt and the base set to 0 so base prefixes are available. Whitespace is trimmed around the integers before parsing to allow for reasonable separtion (shell word-splitting aside)

Types

type NumberError

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

NumberError represents an error when parsing a string to generate a numeric type.

func (*NumberError) Error

func (e *NumberError) Error() string

func (*NumberError) Unwrap

func (e *NumberError) Unwrap() error

type OverflowError

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

OverflowError represents an overflow when casting to a numeric type.

func (*OverflowError) Error

func (e *OverflowError) Error() string

func (*OverflowError) Unwrap

func (e *OverflowError) Unwrap() error

Jump to

Keyboard shortcuts

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