scalar

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2022 License: BSD-2-Clause Imports: 9 Imported by: 10

README

GoDoc Build Status Coverage Status Report Card

Scalar parsing library

Scalar is a library for parsing strings into arbitrary scalars (integers, floats, strings, booleans, etc). It is helpful for tasks such as parsing strings passed as environment variables or command line arguments.

go get github.com/alexflint/go-scalar

The main API works as follows:

var value int
err := scalar.Parse(&value, "123")

There is also a variant that takes a reflect.Value:

var value int
err := scalar.ParseValue(reflect.ValueOf(&value), "123")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanParse

func CanParse(t reflect.Type) bool

CanParse returns true if the type can be parsed from a string.

func Parse

func Parse(dest interface{}, s string) error

Parse assigns a value to v by parsing s.

func ParseValue

func ParseValue(v reflect.Value, s string) error

ParseValue assigns a value to v by parsing s.

Types

This section is empty.

Jump to

Keyboard shortcuts

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