/usr/share/gocode/src/github.com/GeertJohan/go.incremental/int64.go is in golang-github-geertjohan-go.incremental-dev 0.0~git20161212.0.1172aab-2.
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 22 23 24 25 26 27 28 29 30 | package incremental
import (
"sync"
)
type Int64 struct {
increment int64
lock sync.Mutex
}
// Next returns with an integer that is exactly one higher as the previous call to Next() for this Int64
func (i *Int64) Next() int64 {
i.lock.Lock()
defer i.lock.Unlock()
i.increment++
return i.increment
}
// Last returns the number (int64) that was returned by the most recent call to this instance's Next()
func (i *Int64) Last() int64 {
return i.increment
}
// Set changes the increment to given value, the succeeding call to Next() will return the given value+1
func (i *Int64) Set(value int64) {
i.lock.Lock()
defer i.lock.Unlock()
i.increment = value
}
|