autoinc

package module
v0.0.0-...-eab5e8f Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 2 Imported by: 1

README

go-autoinc

Package autoinc implements a serial AUTO_INCREMENT type, for the Go programming language.

This is similar to the AUTO_INCREMENT found in many databases.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-autoinc

GoDoc

Examples

Here is an example autoincional-type that can hold a string:

import "github.com/reiver/go-autoinc"

//

var serial autoinc.AutoInc[uint64]

// ...

next, err := serial.Next()

Import

To import package autoinc use import code like the following:

import "github.com/reiver/go-autoinc"

Installation

To install package autoinc do the following:

GOPROXY=direct go get github.com/reiver/go-autoinc

Author

Package autoinc was written by Charles Iliya Krempeaux

Documentation

Index

Constants

View Source
const (
	ErrNilReceiver = erorr.Error("nil receiver")
	ErrOverFlow    = erorr.Error("overflow")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoInc

type AutoInc[T incrementable] struct {
	// contains filtered or unexported fields
}

AutoInc is an implementation of an AUTO_INCREMENT type.

AutoInc is thread-safe. I.e., AutoInc is safe to use with go-routines.

func (*AutoInc[T]) Current

func (receiver *AutoInc[T]) Current() T

Current returns the current AUTO_INCREMENT value.

If you are not sure whether to to use Current or to use [Next], use [Next].

func (*AutoInc[T]) Next

func (receiver *AutoInc[T]) Next() (T, error)

Next returns the next AUTO_INCREMENT value.

If you are not sure whether to to use Next or to use [Current], use Next.

Jump to

Keyboard shortcuts

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