Discover books, shows, and movies at your level. Track your progress by filling your Shelf with what you find, and share with other language learners. *No dusting required. shlf.space
at master 47 lines 924 B view raw
1package main 2 3import ( 4 "maps" 5 "reflect" 6 "strings" 7 8 "github.com/bluesky-social/indigo/mst" 9 cbg "github.com/whyrusleeping/cbor-gen" 10 11 "shlf.space/api/shlf" 12) 13 14func main() { 15 var typVals []any 16 for _, typ := range mst.CBORTypes() { 17 typVals = append(typVals, reflect.New(typ).Elem().Interface()) 18 } 19 20 genCfg := cbg.Gen{ 21 MaxStringLength: 1_000_000, 22 } 23 24 shlfTypes := []any{ 25 shlf.ActorProfile{}, 26 } 27 28 for name, rt := range AllLexTypes() { 29 if strings.HasPrefix(name, "space.shlf.") { 30 shlfTypes = append(shlfTypes, reflect.New(rt).Interface()) 31 } 32 } 33 shlfGenCfg := genCfg 34 shlfGenCfg.SortTypeNames = true 35 36 if err := shlfGenCfg.WriteMapEncodersToFile("api/shlf/cbor_gen.go", "shlf", shlfTypes...); err != nil { 37 panic(err) 38 } 39} 40 41var lexTypesMap map[string]reflect.Type 42 43func AllLexTypes() map[string]reflect.Type { 44 out := make(map[string]reflect.Type, len(lexTypesMap)) 45 maps.Copy(out, lexTypesMap) 46 return out 47}