https://github.com/qbart/risky
Go library that favors defaults over errors when parsing input.
https://github.com/qbart/risky
Last synced: 4 months ago
JSON representation
Go library that favors defaults over errors when parsing input.
- Host: GitHub
- URL: https://github.com/qbart/risky
- Owner: qbart
- Created: 2023-10-21T03:07:36.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-08T20:04:13.000Z (4 months ago)
- Last Synced: 2025-02-08T21:19:19.391Z (4 months ago)
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# risky go library
Risky parses strings into corresponding types but ignores errors and default or zero values are returned instead.
Bit unsafe but gives values when you need them or you can trust the input.
## Usage
```go
type Animal struct {
Name string
}risky.JSON[Animal](`{"name":"kiwi"}`) // returns an instance of struct{Name: "kiwi"}
risky.JSON[Animal](`abc`) // returns zero value of struct{Name: ""}
risky.ParseInt("123") // returns 123
risky.ParseInt("invalid") // returns 0
```