Skip to content

Commit fbf6da3

Browse files
jorbaumchombium
authored andcommitted
Decrement via AddUint64(&x, ^uint64(0))
This decrements the uint64 var like documentation states it, see https://pkg.go.dev/sync/atomic#AddUint64
1 parent 06a79fd commit fbf6da3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/metricemitter/gauge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (m *Gauge) Increment(value float64) {
4848

4949
// Decrement decrements the gauge by a specified value.
5050
func (m *Gauge) Decrement(value float64) {
51-
atomic.AddUint64(&m.value, toUint64(-value, 2))
51+
atomic.AddUint64(&m.value, ^uint64(toUint64(value, 2)-1))
5252
}
5353

5454
// GetValue atomically returns the current value of the gauge.

0 commit comments

Comments
 (0)