Documentation ¶
Overview ¶
Example ¶
package main import ( "encoding/json" "fmt" "github.com/k1LoW/stopw" ) func main() { stopw.Start() stopw.Start("sub span A") // do something for `sub span A` stopw.Start("sub span B") // do something for `sub span A` or `sub span B` stopw.Start("sub span A", "sub sub span a") // do something for `sub span A` or `sub span B` or `sub sub span a` stopw.Stop("sub span A", "sub sub span a") // do something for `sub span A` or `sub span B` stopw.Stop("sub span span A") // do something for `sub span B` stopw.Stop() r := stopw.Result() b, _ := json.MarshalIndent(r, "", " ") fmt.Println(string(b)) }
Output:
Index ¶
- func Reset()
- func Stop(ids ...any)
- func StopAt(end time.Time, ids ...any)
- type Span
- func (s *Span) Copy() *Span
- func (s *Span) Disable() *Span
- func (s *Span) Elapsed() time.Duration
- func (s *Span) Enable() *Span
- func (s *Span) IDs() []any
- func (s *Span) MarshalJSON() ([]byte, error)
- func (s *Span) New(ids ...any) *Span
- func (s *Span) Repair()
- func (s *Span) Reset()
- func (s *Span) Result() *Span
- func (s *Span) Start(ids ...any) *Span
- func (s *Span) StartAt(start time.Time, ids ...any) *Span
- func (s *Span) Stop(ids ...any)
- func (s *Span) StopAt(end time.Time, ids ...any)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Span ¶ added in v0.4.0
type Span struct { ID any `json:"id,omitempty"` StartedAt time.Time `json:"started_at"` StoppedAt time.Time `json:"stopped_at"` Breakdown spans `json:"breakdown,omitempty"` // contains filtered or unexported fields }
func (*Span) MarshalJSON ¶ added in v0.8.0
Click to show internal directories.
Click to hide internal directories.