Source File
writer.go
Belonging Package
internal/trace
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package trace
import
// Writer is a test trace writer.
type Writer struct {
bytes.Buffer
}
func () *Writer {
:= new(Writer)
.Write([]byte("go 1.9 trace\x00\x00\x00\x00"))
return
}
// Emit writes an event record to the trace.
// See Event types for valid types and required arguments.
func ( *Writer) ( byte, ...uint64) {
:= byte(len()) - 1
if > 3 {
= 3
}
:= []byte{ | <<6}
if == 3 {
= append(, 0)
}
for , := range {
= appendVarint(, )
}
if == 3 {
[1] = byte(len() - 2)
}
, := .Write()
if != len() || != nil {
panic("failed to write")
}
}
func appendVarint( []byte, uint64) []byte {
for ; >= 0x80; >>= 7 {
= append(, 0x80|byte())
}
= append(, byte())
return
}
The pages are generated with Golds v0.6.9-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |