counter.gno
0.41 Kb ยท 25 lines
1package launchpad
2
3// Counter manages unique incrementing IDs.
4type Counter struct {
5 id int64
6}
7
8// NewCounter creates a new Counter starting at 0.
9func NewCounter() *Counter {
10 return &Counter{
11 id: 0,
12 }
13}
14
15// Next increments the counter and returns the next ID.
16func (c *Counter) Next() int64 {
17 c.id++
18
19 return c.id
20}
21
22// Get returns the current ID without incrementing.
23func (c *Counter) Get() int64 {
24 return c.id
25}