map-of-shame - Unsafe operations on type-erased maps (Experimental)
github.com·3h·
Discuss: r/golang
Flag this post

map-of-shame

⚠️ EXPERIMENTAL - DO NOT USE IN REAL SYSTEMS ⚠️

map-of-shame provides direct access to Go’s internal map implementation through unsafe pointers.

Some code needs to perform operations on maps whose type is not known at compile time. Normally, this is done using reflection, which enforces various safety guarantees and prevents consumers from violating expectations of the runtime. However, this requires causes a large performance overhead - mainly by forcing most operations to allocate memory. The only alternative to this is to break the encapsulation of the runtime and expose internal functions and reimplement private types.

This library provides a thin wrapper around these exposed operations, so that consumers can merely focus on writing unsafe code.

You shoul…

Similar Posts

Loading similar posts...