I just created go-picker: a small Go library for picking values from maps, typically parsed JSON.
github.comΒ·17hΒ·
Discuss: r/golang
Flag this post

go-picker

Clean, readable JSON data extraction for Go without the bloat of repetitive error checking.

Go-picker lets you write clean, readable code for extracting values from JSON data. Instead of checking errors after every operation, you focus on your business logic and validate everything at the end with a single Confirm() call.

The Problem

Traditional JSON parsing in Go is verbose and error-prone:

// Traditional approach - bloated with error checking
userObj, ok := data["user"].(map[string]interface{})
if !ok {
return errors.New("invalid user")
}

name, ok := userObj["name"].(string)
if !ok {
return errors.New("invalid name")
}

age, ok := userObj["age"].(float64)
if !ok {
return errors.New("invalid age")
}

profileObj, ok := userObj["profile"].(map[string]inte...

Similar Posts

Loading similar posts...