Learn to code by coding - try our free CS courses

Concurrency In Rust; Can It Stack Up Against Go’s Goroutines?

photo 1518181835702 6eef8b4b2113

One of the primary goals of the Go programming language is to make concurrency simpler, faster, and more efficient. With Rust growing in popularity let’s see how its concurrency mechanisms stack up against Go’s. A Refresher On Goroutines In Go, concurrency is accomplished by spawning new goroutines: In the example above, we use the go …

Read more

Rust vs Go – Which Is More Popular?

Rust vs Go; Which is More Popular

Go and Rust are two of the hottest compiled programming languages, but which is more popular, Go or Rust?. I develop in Go full-time and love it, and I’m learning more about Rust recently – it’s an exciting language. Let’s explore some differences between the two and look at which is growing faster in the …

Read more

Range Over Ticker In Go With Immediate First Tick

Profile Tick Toc Croc

The Go standard library has a really cool type – Ticker. Tickers are used when you want to do something at a regular interval, similar to JavaScript’s setInterval. Here’s an example: As per the docs, a ticker is a struct that holds a receive-only channel of time.Time objects. In the example at the beginning of …

Read more

Using a Low-Level RabbitMQ Client in Golang

Rabbit in Go Cuddly

RabbitMQ is a great message broker with awesome Golang support. It’s a great pub-sub system, and pub-sub has become a staple communication architecture in micro-services. At my current day job, we use RabbitMQ to push hundreds of millions of social media posts through our Go services daily. In this post, we’re going to go over …

Read more

Using ‘Go Generate’ To Deploy Multi-Process Apps

GE 740x520 1

In microservice architectures, it’s fairly common to have a project that includes different worker types. A Makefile can be used to manage the creation of multiple programs, but the Go toolchain has a tool that can be used as well, go generate. Here are some examples of how it can be used: API/Worker – We …

Read more

What Are Golang’s Anonymous Structs?

anonymous

An anonymous struct is just like a normal struct, but it is defined without a name and therefore cannot be referenced elsewhere in the code. Structs in Go are similar to structs in other languages like C. They have typed collections of fields and are used to group data to make it more manageable for …

Read more

Announcing Go-TinyTime, Go-TinyDate’s Sister Package

tinyclock

time.Time is the perfect choice for handling times in Go in most cases, it even comes in the standard library! The problem is that the time.Time{} struct uses more than 24 bytes of memory under most conditions. Go-TinyTime solves this problem by restricting the available dates to the range between 1970 – 2106, and only …

Read more

How To Separate Library Packages in Go

photo 1550535424 b498819c412f

I’ve often seen, and have been responsible for, throwing code into packages without much thought. I’ve quickly drawn a line in the sand and started putting code into different folders (which in Go are different packages by definition) just for the sake of findability. Learning to properly build small and reusable packages can take your …

Read more