May 28, 2021 | 04:50

Go Performance Tools Cheat Sheet

Go has a lot of tools available for you to understand where your application might be spending CPU time or allocating memory. I don’t use these tools daily so I always end up searching for the same thing every time. This post aims to be a reference document for everything that Go has to provide. We’ll be using https://gitlab.com/steveazz-blog/go-performance-tools-cheat-sheet as a demo project and there are 3 implementations of the same thing, one more performant than the other. Read more

April 3, 2021 | 00:00

import "context"

What can you do when you import "context" inside of your go project? Looking at the source code it’s a fairly small package and provides a small api. We also see this package imported almost everywhere and the standard library also uses it. context provides the following functionality: Cancellation Context scope values Deadlines/Timeouts There are two things that you need to keep in mind when you are using context: Read more
#TIL | #Go

July 21, 2020 | 20:03

Go Trace Shortcut

You can use the go trace tool to look at the CPU traces to see how your program is behaving for example. package main import ( "fmt" "os" "runtime/trace" ) func main() { f, err := os.Create("trace.out") if err != nil { panic(err) } defer f.Close() err = trace.Start(f) if err != nil { panic(err) } trace.Stop() fmt.Println("hello") } When you run the program you will see a new file trace. Read more