Show HN

Kanna

by @mickamy

Kanna – Go generators for DI, queries, internationalization and more I kept writing constructor wiring up, domain types and API types conversions, test fixtures, DB row scans, bra-bra-brah by my hands. I know that libraries those use reflections may help, but they fails on runtime and we cannot see what is happening without reading code. So I decided to create a project in oposite hand. Generate code and put it in our repository. The code is ordinary Go code, so that we can review, watch diffs and also debug it. For instance, when we have the following code, func NewDB() DB { return &DB{} } func NewUser(db DB) User { return User{db: db} } type Container struct { User User `di:""` } it generates... func NewContainer() *Container { db := NewDB() user := NewUser(db) return &Container{User: user} } No providers, just scan packages and find them. There are 5 generators. 1. DI 2. Struct to struct mapping (for protubf and so on) 3. Test fixtures (from model to them) 4. SQL queries (like an sqlc but without SQL and more like GORM) 5. Type safe i18n All we need is just a struct and tags. Project is just started and just hit v0.0.1. Any feedbacks are very welcome.

Discover more builders

Builderlust is an endless, joyful scroll of real projects people are shipping right now. Get the app to keep finding your next spark of inspiration.

📱 Coming soon to iOS & AndroidOpen in the app