Mastering Go Application Design: Building a Basic CLI from Scratch with Only the Standard Library

Golang has built in support for creating CLI applications that accept command line flags and arguments. The “flag” package has convenient methods for reading in options as typed variables, it also supports creating default help text. CLI applications are useful for creating developer tooling, especially when you can import critical parts of the codebase into a simple cli. Playground: https://go.dev/play/p/UHuXCNgQB8j package main import "flag" var ( // define the command line arguments customerID *int = flag....

Mastering Go Application Design: Simplify Complex Systems With a Diagram

Diagraming your applications can be a useful exercise. It can give you a chance to think clearly about what already exists, what you plan to create and how it will work. Some of the best systems I’ve designed were complete mysteries to me, then I took time to diagram what already existed and it helped me see what needed to be created next. Diagrams can also be extremely valuable documentation, even if they are slightly out of date....

Mastering Go Concurrency: Running Background Tasks with Goroutines (Part 5)

Part 1 , Part 2 , Part 3 , Part 4 , Part 5 Goroutines can be used to start independent long running task. These tasks can be entire microservices, which is very useful for creating a single application with multiple system responsibilities. The select statement will block and wait for a channel to be ready for reading, then after reading from the channel the code will be executed. Playground: https://go....

Mastering Concurrency in Go: Decoupling Data Transfer With Buffered Channels (Part 4)

Part 1 , Part 2 , Part 3 , Part 4 , Part 5 Buffered Channels in Go are similar to unbuffered channels, but they allow a writer to write without blocking if the channel is not full, which can be useful for concurrent data processing where the reader needs to be decoupled. However, using buffered channels can consume memory even when the buffer is empty, so they should be used with care....

Concurrency Limiting in Go Maximizing Application Efficiency and Resource Utilization

Playground , Repo Why do you need concurrency limiting? Concurrency limiting in your go application might be necessary to limit overuse of a specific resource. This could be an API rate limit, slow network connection, slow disk I/O operation or limited CPU/RAM. Starting a huge number of go routines that use a limited resource could cause your application to crash. If you are experiencing crashes or errors on a resource intensive task then I would recommend implementing a concurrency limiter....