-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc01392
commit f03db3d
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# slicestrconv | ||
|
||
[](https://pkg.go.dev/github.com/MatusOllah/slicestrconv) [](https://goreportcard.com/report/github.com/MatusOllah/slicestrconv) | ||
|
||
**slicestrconv** is a string to slice converting / parsing library for Go. Like strconv but for slices. | ||
|
||
## Basic Usage | ||
|
||
```go | ||
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] | ||
} | ||
``` |