autoinc

package
v0.0.0-...-38fe691 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2015 License: MIT Imports: 0 Imported by: 4

README

AutoInc

AutoInc can generate integers from start with step. This library is safe for concurrent use.

Example

import (
	"fmt"
	"sync"
	// import the library
	"github.com/mikespook/golib/autoinc"
)

const (
	Start = 0
	End   = 100
	Step  = 2
)

func main() {
	var wg sync.WaitGroup
	
	// get the instance
	ai := autoinc.New(Start, Step)
	// close the counter
	defer ai.Close()
	for i := Start; i < End; i++ {
		wg.Add(1)
		go func() {
			// get an integer and print it
			fmt.Println(ai.Id())
			wg.Done()
		}()
	}
	wg.Wait()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoInc

type AutoInc struct {
	// contains filtered or unexported fields
}

func New

func New(start, step int) (ai *AutoInc)

func (*AutoInc) Close

func (ai *AutoInc) Close()

func (*AutoInc) Id

func (ai *AutoInc) Id() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL