package version
import (
"fmt"
"io"
"internal/trace/tracev2"
)
type Version uint32
const (
Go111 Version = 11
Go119 Version = 19
Go121 Version = 21
Go122 Version = 22
Go123 Version = 23
Go125 Version = 25
Current = Go125
)
var versions = map [Version ][]tracev2 .EventSpec {
Go111 : nil ,
Go119 : nil ,
Go121 : nil ,
Go122 : tracev2 .Specs ()[:tracev2 .EvUserLog +1 ],
Go123 : tracev2 .Specs ()[:tracev2 .EvExperimentalBatch +1 ],
Go125 : tracev2 .Specs (),
}
func (v Version ) Specs () []tracev2 .EventSpec {
return versions [v ]
}
func (v Version ) EventName (typ tracev2 .EventType ) string {
if !v .Valid () {
return "<invalid trace version>"
}
s := v .Specs ()
if len (s ) == 0 {
return "<v1 trace event type>"
}
if int (typ ) < len (s ) && s [typ ].Name != "" {
return s [typ ].Name
}
return fmt .Sprintf ("Invalid(%d)" , typ )
}
func (v Version ) Valid () bool {
_ , ok := versions [v ]
return ok
}
const headerFmt = "go 1.%d trace\x00\x00\x00"
func ReadHeader (r io .Reader ) (Version , error ) {
var v Version
_ , err := fmt .Fscanf (r , headerFmt , &v )
if err != nil {
return v , fmt .Errorf ("bad file format: not a Go execution trace?" )
}
if !v .Valid () {
return v , fmt .Errorf ("unknown or unsupported trace version go 1.%d" , v )
}
return v , nil
}
func WriteHeader (w io .Writer , v Version ) (int , error ) {
return fmt .Fprintf (w , headerFmt , v )
}
The pages are generated with Golds v0.7.7-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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .