Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.27 KB

gotracer.md

File metadata and controls

47 lines (37 loc) · 1.27 KB

Go Tracer

an introduction to go tool trace and describing how you can use it to debug concurrent Go programs. Go makes it easy to use concurrency with goroutines, which means we do more concurrency, which means we have more concurrency problems.

Large File Read challenge

How to generate trace.out file?

copy and paste the following code into your main function

func main(){
	//go tool trace
	f, err := os.Create("trace.out")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	err = trace.Start(f)
	if err != nil {
		panic(err)
	}
	defer trace.Stop()
	//------------------------
  
  //your prgram source code goes here
  
  }
  

run your go program using

go run main.go

run following code to open trace.out file in your browser

go tool trace trace.out

Memory allocation debug

GODEBUG=gctrace=1 go run .

Max processor set

GOMAXPROCS=3 go run .

Reference