Redefining Go Functions
Summary
The post explores how, in Go, you can conceptually redefine a function at runtime using memory tricks (reflect to get a function address, unsafe slices to view bytes, and mprotect to modify permissions) and then redirect execution with a JMP. It demonstrates replacing time.Now with a custom time source, discusses the hazards (segmentation faults, memory protection issues, inline functions), and shares a Go package for experimentation while warning against using this in production.