Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Another underused language feature is the "reflect" package, which for me is the most powerful meta-programming tool that Go offers: It basically allows you to introspect data structures at runtime, in combination with struct tags (e.g. commonly used in the json package like `json:"foo"`) it becomes really really powerful. I've written automated database mapping / ORM code and struct deserialization code with it (e.g. here were we build a function that serializes arbitrary JSON-like data structures into deeply nested structs: https://github.com/kiprotect/go-helpers/blob/master/forms/co...), but you could do even more powerful things like completely automated generation of gRPC/REST interfaces at runtime.

Another interesting but underused capability are go plugins, which allow us to dynamically load external code at runtime. They are similar to DLLs but unfortunately not as powerful as they e.g. need to be compiled against the exact same Go version & runtime. We still use them at various points in our codebase (e.g. here: https://github.com/kiprotect/kodex/tree/master/plugins/write...).



Plugins are half-done feature, I would like for them to finish the implementation across all supported OSes and improve the way the code gets loaded as well.

Hence why they are underused.


I wouldn't say reflection is being underused.

It's just that the reflection is a powerful tool AND a necessary evil.

https://blog.golang.org/laws-of-reflection

"Once you understand these laws reflection in Go becomes much easier to use, although it remains subtle. It's a powerful tool that should be used with care and avoided unless strictly necessary."




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: