Lessons Learned: GoLang GORM – filtering associations

The problem Given the following code: type User struct { gorm.Model Username string Orders []Order } type Order struct { gorm.Model UserID uint Foobar string } The above Golang code defines a "Has Many" association, leading to a schema where a "User" "has many" "Orders", with the "user_id" key acting as a foreign key. How … Continue reading Lessons Learned: GoLang GORM – filtering associations

Simple DNS Sniffer in GoLang

Golang makes it really simple to code some otherwise arduous tasks. In this case, we needed to sniff raw network data, filter out DNS data, and send the DNS queries and responses to an Elasticsearch cluster. The resulting code is surprisingly simple thanks to libraries such as GoPacket, as you can see below: https://gist.github.com/dvas0004/3d280f95a83a3084b314ea208f19f9e9 The … Continue reading Simple DNS Sniffer in GoLang

Practical embedding in GoLang

Eric Urban has written a phenomenal blog post about embedding in Golang: http://www.hydrogen18.com/blog/golang-embedding.html Embedding in Golang is an important concept to  grasp, especially when coming from an object-oriented paradigm, since as Eric describes, embedding in Golang is superficially similar to OO's inheritance concept. I came across a practical need for doing this when dealing with … Continue reading Practical embedding in GoLang

Nugget Post: Golang HTML Templates

Golang authors have an excellent article on how to build a wiki web application entirely out of go. Towards the middle of the article, they mention the html/template package. For those of you familiar with templating systems like jade, handlebars, or flask/jinja... you should feel right at home. In golang, templating needs no third party frameworks, no … Continue reading Nugget Post: Golang HTML Templates

Nugget Post: Golang: RPC server/client implementation

As part of my efforts to learn golang, I attempted to write a simple RPC server / client implementation. Between gobs (see my previous post) and the RPC implementation, golang makes it very easy to build a distributed system where servers and client share not only data via gobs, but also methods and functions via … Continue reading Nugget Post: Golang: RPC server/client implementation

Nugget Post: Golang : Gobs and exported identifiers

This one had me scratching my head for a while... while messing around with "gobs" - binary representation of data that can be sent over the network between two golang programs - I ran into the problem of "exported fields". I had followed the post on the golang blog regarding gobs, with some modifications. I … Continue reading Nugget Post: Golang : Gobs and exported identifiers