| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/go-1.23/src/internal/trace/ |
Upload File : |
// Copyright 2023 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 "fmt"
// Value is a dynamically-typed value obtained from a trace.
type Value struct {
kind ValueKind
scalar uint64
}
// ValueKind is the type of a dynamically-typed value from a trace.
type ValueKind uint8
const (
ValueBad ValueKind = iota
ValueUint64
)
// Kind returns the ValueKind of the value.
//
// It represents the underlying structure of the value.
//
// New ValueKinds may be added in the future. Users of this type must be robust
// to that possibility.
func (v Value) Kind() ValueKind {
return v.kind
}
// Uint64 returns the uint64 value for a MetricSampleUint64.
//
// Panics if this metric sample's Kind is not MetricSampleUint64.
func (v Value) Uint64() uint64 {
if v.kind != ValueUint64 {
panic("Uint64 called on Value of a different Kind")
}
return v.scalar
}
// valueAsString produces a debug string value.
//
// This isn't just Value.String because we may want to use that to store
// string values in the future.
func valueAsString(v Value) string {
switch v.Kind() {
case ValueUint64:
return fmt.Sprintf("Uint64(%d)", v.scalar)
}
return "Bad"
}