package main import ( "maps" "reflect" "strings" "github.com/bluesky-social/indigo/mst" cbg "github.com/whyrusleeping/cbor-gen" "shlf.space/api/shlf" ) func main() { var typVals []any for _, typ := range mst.CBORTypes() { typVals = append(typVals, reflect.New(typ).Elem().Interface()) } genCfg := cbg.Gen{ MaxStringLength: 1_000_000, } shlfTypes := []any{ shlf.ActorProfile{}, } for name, rt := range AllLexTypes() { if strings.HasPrefix(name, "space.shlf.") { shlfTypes = append(shlfTypes, reflect.New(rt).Interface()) } } shlfGenCfg := genCfg shlfGenCfg.SortTypeNames = true if err := shlfGenCfg.WriteMapEncodersToFile("api/shlf/cbor_gen.go", "shlf", shlfTypes...); err != nil { panic(err) } } var lexTypesMap map[string]reflect.Type func AllLexTypes() map[string]reflect.Type { out := make(map[string]reflect.Type, len(lexTypesMap)) maps.Copy(out, lexTypesMap) return out }