
You may want the build to create binary for multiple OS. If you want a different binary name and also want to create a build for a specific OS, you can specify this during the build: GOARCHamd64 GOOSdarwin go build -o hello-world main.go. Similarly, we can also see a graph of CPU with command – go tool pprof -http :8080 cpu. To run this project, you would normally need to build the project and run the binary: go build main.go. Let’s see how our benchmark changes after removing fmt.Sprintf(). So we are going to use strconv.Itoa() instead. Here we can see our Sprintf method is using a lot of memory. This will start an HTTP server on port 8080 and open URL – which will display how memory is getting allocated. The io.Writer interface it’s one of Go’s very small interfaces. Let’s use go tool pprof -http :8080 mem.out command. Salaries Companies Developers Go (Golang) io.Writer Example. Not different from our previous command but the files are created.

The output of this command will be like below, benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out We will look into the go tool pprof part today.įirst, let’s create the profiles, We will be creating 3 files which will contain profiles for the following -cpuprofile, -memprofile, -trace We can use pprof as a web server or with go tool pprof. Pprof is basically the profiling tool/package provided in the standard library.
