slicestrconv

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 3 Imported by: 1

README

slicestrconv

Go Reference Go Report Card

slicestrconv is a string to slice converting / parsing library for Go. Like strconv but for slices.

Basic Usage

package main

import (
    "fmt"

    "github.com/MatusOllah/slicestrconv"
)

func main() {
    boolSlice, err := slicestrconv.ParseBoolSlice("[true, false, true]")
    if err != nil {
        panic(err)
    }

    fmt.Println(boolSlice) // [true false true]

    intSlice, err := slicestrconv.ParseIntSlice("[1, 2, 3, 420, 69]", 10)
    if err != nil {
        panic(err)
    }

    fmt.Println(intSlice) // [1 2 3 420 69]

    floatSlice, err := slicestrconv.ParseFloatSlice("[1.1, 2.2, 3.3, 3.14]", 10)
    if err != nil {
        panic(err)
    }

    fmt.Println(floatSlice) // [1.1 2.2 3.3 3.14]
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OpeningBracket string = "["
	ClosingBracket string = "]"
	Delimiter      string = ","
)
View Source
var (
	ErrInvalidSyntax error = errors.New("invalid slice syntax")
)

Functions

func ParseBoolSlice

func ParseBoolSlice(s string) ([]bool, error)

ParseBoolSlice parses and returns the []bool slice represented by the string s.

func ParseComplex128Slice

func ParseComplex128Slice(s string, base int) ([]complex128, error)

ParseComplex128Slice parses and returns the []complex128 slice represented by the string s.

func ParseComplex64Slice

func ParseComplex64Slice(s string, base int) ([]complex64, error)

ParseComplex64Slice parses and returns the []complex64 slice represented by the string s.

func ParseFloat32Slice

func ParseFloat32Slice(s string, base int) ([]float32, error)

ParseFloat32Slice parses and returns the []float32 slice represented by the string s.

func ParseFloat64Slice

func ParseFloat64Slice(s string, base int) ([]float64, error)

ParseFloat64Slice parses and returns the []float64 slice represented by the string s.

func ParseInt16Slice

func ParseInt16Slice(s string, base int) ([]int16, error)

ParseInt16Slice parses and returns the []int16 slice represented by the string s.

func ParseInt32Slice

func ParseInt32Slice(s string, base int) ([]int32, error)

ParseInt32Slice parses and returns the []int32 slice represented by the string s.

func ParseInt64Slice

func ParseInt64Slice(s string, base int) ([]int64, error)

ParseInt64Slice parses and returns the []int64 slice represented by the string s.

func ParseInt8Slice

func ParseInt8Slice(s string, base int) ([]int8, error)

ParseInt8Slice parses and returns the []int8 slice represented by the string s.

func ParseIntSlice

func ParseIntSlice(s string, base int) ([]int, error)

ParseIntSlice parses and returns the []int slice represented by the string s.

func ParseUint16Slice

func ParseUint16Slice(s string, base int) ([]uint16, error)

ParseUint16Slice parses and returns the []uint16 slice represented by the string s.

func ParseUint32Slice

func ParseUint32Slice(s string, base int) ([]uint32, error)

ParseUint32Slice parses and returns the []uint32 slice represented by the string s.

func ParseUint64Slice

func ParseUint64Slice(s string, base int) ([]uint64, error)

ParseUint64Slice parses and returns the []uint64 slice represented by the string s.

func ParseUint8Slice

func ParseUint8Slice(s string, base int) ([]uint8, error)

ParseUint8Slice parses and returns the []uint8 slice represented by the string s.

func ParseUintSlice

func ParseUintSlice(s string, base int) ([]uint, error)

ParseUintSlice parses and returns the []uint slice represented by the string s.

Types

This section is empty.

Jump to

Keyboard shortcuts

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