David Pointer

All Categories: go(2) home

Casting Go interface to struct

Learning to think in Go

I was using an excellent go icmp library recently. I got hung up on dealing with a received MessageBody type that I knew was really an Echo type, but I could not refer to the fields in the Echo struct. I think my C/C++/Python background got in my way here.

After a bit of head scratching, I noticed the MessageBody type was defined an . . .

Read More

Posted in: go

February 20, 2019

Simple defer'd Error Handling in Go

I recently wrote a Go func that starts off by opening a network listening connection and defers closing that connection.

connection, err := icmp.ListenPacket(...)
if err != nil {
defer connection.Close()

The defer'd connection.Close()returns an error, but how to capture and do something with that . . .

Read More

Posted in: go

February 15, 2019


All Categories: go(2) home

This update link alerts you to new Silvrback admin blog posts. A green bubble beside the link indicates a new post. Click the link to the admin blog and the bubble disappears.

Got It!