
Implementing a network protocol in Go - beliu
https://about.sourcegraph.com/go/gophercon-2018-implementing-a-network-protocol-in-go/
======
beliu
Sourcegraph CTO/liveblogger of this talk here. This was an excellent session
that basically walks you through line-by-like, layer-by-layer how to implement
the IPv6 Neighbor Discovery Protocol (analog to IPv4’s ARP). Highly recommend
for folks who like networking, diving into source code, or Go.

You can dive straight into the source here:
[https://sourcegraph.com/github.com/mdlayher/ndp/-/blob/messa...](https://sourcegraph.com/github.com/mdlayher/ndp/-/blob/message.go#L27:6-27:13&tab=references)

------
mdlayher
Hey folks, presenter here! Happy to answer any questions you all may have, and
thanks again to Sourcegraph for the live blog!

~~~
ArtWomb
Great stuff!

This is actually a powerful design pattern in golang. Write first without
worrying about bottlenecks. Make sure all tests are ok. And typically
concurrent GC is performant enough for average loads.

Then later at our leisure we can optimize with pprof and custom load
generator. With bonus points for go-fuzz and throwing in some chaos ;)

But for ARP style table lookups, do you even need to allocate for the
response? Are we actually doing any request processing? Can't we just output
the cache entry to the net io.Writer, log the event, and continue?

~~~
weberc2
io.Writer takes a byte slice as an argument and the escape analyzer can’t see
through the interface, so it would be allocated anyway, I believe.

