Range Over Ticker In Go With Immediate First Tick

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 Range Over Ticker In Go With Immediate First Tick

Best Practices For Writing Clean Interfaces in Go

Interfaces allow us to treat different types as the same type when it comes to specific behaviors. They are central to a Go programmers toolbelt and are often used improperly by new Go developers… leading to hard to read and buggy code. Recap on Interfaces Let’s look to the standard library as an example of … Read more Best Practices For Writing Clean Interfaces in Go

Guard Clauses: How to clean up Conditionals

One of the first techniques developers learn is the if/else statement. For obvious reasons if/else statements are a primary way to create logic trees. This is where we handle calculations differently depending on the input variables. However, complex and nested if/else statements become a cognitive burden to reason about. Therefore, it can be hard for … Read more Guard Clauses: How to clean up Conditionals