sliceparse

package
v0.0.0-...-d2356ba Latest Latest
Warning

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

Go to latest
Published: May 19, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package sliceparts contains routines to parse components of string slices into string, int32, and int64 variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Consume

func Consume(input []string, output ...interface{}) (remaining []string, err error)

Consume parses len(output) elements of input into their respective output variables. Each output must be a pointer to a supported type. What is stored to the output depends on its type:

*string: input[i] is directly copied
*int32: strconv.ParseInt(input[i], 10, 32) is called
*int64: strconv.ParseInt(input[i], 10, 64) is called

If an output element is a nil interface{}, the associated input element is skipped. A nil pointer value is also accepted - in that case the input element is validated but no attempt to store it is made.

If len(output) > len(input), an error is returned.

If any output has an unsupported type, an error is returned.

If strconv.ParseInt returns an error for any integer output, its error is returned.

Otherwise, this function returns (input[len(output):], nil).

Types

This section is empty.

Jump to

Keyboard shortcuts

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