Returning stop/cancel functions in #golang
Mat Ryer
446

Love this idea (and I’m off to swap some of my own code to do this…) but I know that defer is well loved, but it has performance penalties that climb the more exit cases your code has doesn’t it? By deferring your stop, aren’t you slowing yourself down? I’d be curious to see what impact that had vs

stop := metric.NewTimer(“defer”)

defer stop()

//do complex work

vs

stop := metric.NewTimer(“not defer”)

//do complex work

stop()

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.