// Prop: a resolved single property value whose zero value means absent --// folding Rust's Option<Prop> + PropExt into one type, so reads chain// directly: g.Prop(n, "age").I64Or(0).package chickpeas// Prop is a property read result. The zero value reads as absent: every// accessor returns not-ok / its default.typePropstruct { g *Snapshot v Value ok bool}// Value returns the raw value; ok is false when the property is absent.func ( Prop) () (Value, bool) {return .v, .ok}// Str returns the string value; ok is false when absent, not a string, or// empty (dense string columns store a missing value as "", so the empty// check callers would otherwise repeat is folded in).func ( Prop) () (string, bool) {if !.ok {return"", false } , := .v.StrID()if ! {return"", false } , := .g.atoms.Resolve()if ! || == "" {return"", false }return , true}// I64 returns the integer value; ok is false when absent or not an integer.func ( Prop) () (int64, bool) {if !.ok {return0, false }return .v.I64()}// F64 returns the float value; ok is false when absent or not a float.func ( Prop) () (float64, bool) {if !.ok {return0, false }return .v.F64()}// Bool returns the boolean value; ok is false when absent or not a boolean.func ( Prop) () (bool, bool) {if !.ok {returnfalse, false }return .v.Bool()}// StrOr returns the string value, or def when absent / not a string / empty.func ( Prop) ( string) string {if , := .Str(); {return }return}// I64Or returns the integer value, or def when absent or not an integer.func ( Prop) ( int64) int64 {if , := .I64(); {return }return}// F64Or returns the float value, or def when absent or not a float.func ( Prop) ( float64) float64 {if , := .F64(); {return }return}// BoolOr returns the boolean value, or def when absent or not a boolean.func ( Prop) ( bool) bool {if , := .Bool(); {return }return}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.