Go AST Viewer - online tool for analysis and visualization of ast

Basic AST Manipulation, Basic AST Traversal in Go - simple technique to modify Go code using AST.

Building an Unbounded Channel in Go The default un-buffered channels pass values from one goroutine to another, one at a time. The goroutine that writes to the channel blocks until another goroutine reads from the same channel. A buffered channel gives writers a bit more flexibility. When a channel is buffered, a set number of values can be written to the channel and not read before the channel blocks. It behaves like a synchronized queue with a bounded size. The post explains how to build Erlang’s style unbounded queues.

Organising Database Access in Go In the context of a web application what would you consider a Go best practice for accessing the database in (HTTP or other) handlers? The post analyses various design pattern they pros and cons.


Standard Package Layout - These are seen as big issues in the Go community but there’s another issue that’s rarely mentioned β€” application package layout.

Go best practices, six years in - Hints and practices to manage Golang project.

Type embedding in Go - Go does not provide the typical, type-driven notion of subclassing, but it does have the ability to β€œborrow” pieces of an implementation by embedding types within a struct or interface. In fact, type embedding is product type composition. The article explains basics behind the embedding.

Errors are values - Error handling in Go is different than other functional programming. Usually Either monad helps a lot. Go programmers miss a fundamental point about errors: Errors are values. The article shows a few patterns on error handling with Go.

Constant errors post show up the issue with sentinel error values in Go, it proposes alternative and type-safe solution to express errors using const. The approach advances error declaration and handling towards behaviour-based approach to inspect errors.

Why doesn’t Go have variance in its type system? - It explain what co-, contra- and invariance are and what the implications for Go’s type system would be. In particular, why it’s impossible to have variance in slices.

Go and Sum Data Types - Sum types is a neat feature of some programming languages that lets us specify that a value might take one of several related types, and includes convenient syntax for pattern matching on these types at run-time.

Functional options on steroids - Functional options is a paradigm in Go for clean and extensible APIs popularized by Dave Cheney and Rob Pike. This post is about the practices that appeared around the pattern since it was first introduced.

JSON and struct composition in Go - Say you are decoding a JSON object into a Go struct. It comes from a service that is not under your control, so you cannot do much about the schema. However, you want to encode it differently.

Dealing with JSON with non-homogeneous types in GO - Dynamic languages supports non-homogeneous schemas out-of-the-box (e.g. [ { "value": "123" }, { "value": 123 } ]). The post explains how to achieve this with type-safe approach in Golang.

Golang Parsing JSON into Interfaces - Interfaces are an incredibly powerful feature in Go, and JSON is one of the most ubiquitous serialization formats in use today. The post explains how to handle sum-type support in JSON with interfaces.

Don’t use Go’s default HTTP client - Go’s http package doesn’t specify request timeouts by default, allowing services to hijack your goroutines. Always specify a custom http.Client when connecting to outside services.

A Simple Web Scraper in Go and Web Scrapping With Golang are easy technic to parse HTML output of website. Most of the online bots are based on same technic to get required information

Iterating Over Slices In Go In Go everything is pass by value. We can pass by value the address of an object or pass by value a copy of an object. That includes function parameters, return values and when iterating over a slice, map or channel.

Recursion And Tail Calls In Go Go does not optimize for recursion, even if tail calls are explicit. The post explains in details a Golang design of recursive calls and how to improve the memory consumption in recursive algorithms.