MCPcopy Create free account
hub / github.com/featureform/featureform / NewStructMap

Function NewStructMap

helpers/struct_map/struct_map.go:46–68  ·  view source on GitHub ↗
(s interface{})

Source from the content-addressed store, hash-verified

44}
45
46func NewStructMap(s interface{}) (*StructMap, error) {
47 t := reflect.TypeOf(s).Kind()
48 if t != reflect.Struct {
49 return nil, fmt.Errorf("cannot create map from type %T", s)
50 }
51
52 v := reflect.ValueOf(s)
53 keys := []string{}
54
55 for i := 0; i < v.NumField(); i++ {
56 field := v.Field(i)
57 if !field.CanInterface() {
58 continue
59 }
60 keys = append(keys, v.Type().Field(i).Name)
61 }
62
63 return &StructMap{
64 keys: keys,
65 size: len(keys),
66 val: v,
67 }, nil
68}

Callers 2

TestNewStructMapFunction · 0.85
TestStructMapGetFunction · 0.85

Calls 1

TypeMethod · 0.65

Tested by 2

TestNewStructMapFunction · 0.68
TestStructMapGetFunction · 0.68