github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/cmd/goimports/goimports_gc.go (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build gc
     6  // +build gc
     7  
     8  package main
     9  
    10  import (
    11  	"flag"
    12  	"runtime/trace"
    13  )
    14  
    15  var traceProfile = flag.String("trace", "", "trace profile output")
    16  
    17  func doTrace() func() {
    18  	if *traceProfile != "" {
    19  		bw, flush := bufferedFileWriter(*traceProfile)
    20  		trace.Start(bw)
    21  		return func() {
    22  			flush()
    23  			trace.Stop()
    24  		}
    25  	}
    26  	return func() {}
    27  }