/usr/share/gocode/src/github.com/paulbellamy/ratecounter/counter.go is in golang-github-paulbellamy-ratecounter-dev 0.2.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package ratecounter
import "sync/atomic"
// A Counter is a thread-safe counter implementation
type Counter int64
// Incr method increments the counter by some value
func (c *Counter) Incr(val int64) {
atomic.AddInt64((*int64)(c), val)
}
// Reset method resets the counter's value to zero
func (c *Counter) Reset() {
atomic.StoreInt64((*int64)(c), 0)
}
// Value method returns the counter's current value
func (c *Counter) Value() int64 {
return atomic.LoadInt64((*int64)(c))
}
|