Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a simple counter that can be incremented, decremented, or set to a specific value.
Example ¶
package main
import (
"time"
"676f.dev/trout/counter"
"github.com/fatih/color"
)
func main() {
c := counter.NewCounter(color.HiCyanString("Hello")+"(", "x)")
time.Sleep(1 * time.Second)
c.Inc()
time.Sleep(1 * time.Second)
c.Inc()
time.Sleep(1 * time.Second)
c.Inc()
time.Sleep(1 * time.Second)
c.End()
}
Output:
func NewCounter ¶
NewCounter creates a counter with the given prefix and suffix.
func NewDefaultCounter ¶ added in v1.0.1
NewDefaultCounter creates a counter with the default (and colored) prefix and suffix.
Example ¶
package main
import (
"time"
"676f.dev/trout/counter"
)
func main() {
c := counter.NewDefaultCounter("test")
time.Sleep(1 * time.Second)
c.Inc()
time.Sleep(1 * time.Second)
c.Inc()
time.Sleep(1 * time.Second)
c.Inc()
time.Sleep(1 * time.Second)
c.End()
}
Output:
Click to show internal directories.
Click to hide internal directories.