Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

fields.gno

0.54 Kb · 23 lines
 1package datasource
 2
 3// NewFieldsFromMap returns read-only fields for a map of field names and values.
 4//
 5// The map is wrapped as is and not copied, so changes made to it by the caller
 6// are also visible through the returned fields.
 7func NewFieldsFromMap(m map[string]any) Fields {
 8	return fields{values: m}
 9}
10
11type fields struct {
12	values map[string]any
13}
14
15func (f fields) Has(name string) bool {
16	_, found := f.values[name]
17	return found
18}
19
20func (f fields) Get(name string) (value any, found bool) {
21	value, found = f.values[name]
22	return value, found
23}