github.com/april1989/origin-go-tools@v0.0.32/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  // +build gc
     6  
     7  package main
     8  
     9  import (
    10  	"flag"
    11  	"runtime/trace"
    12  )
    13  
    14  var traceProfile = flag.String("trace", "", "trace profile output")
    15  
    16  func doTrace() func() {
    17  	if *traceProfile != "" {
    18  		bw, flush := bufferedFileWriter(*traceProfile)
    19  		trace.Start(bw)
    20  		return func() {
    21  			flush()
    22  			trace.Stop()
    23  		}
    24  	}
    25  	return func() {}
    26  }