Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ybubnov/go-uuid

A wrapper for Linux kernel UUID v4 generator.
https://github.com/ybubnov/go-uuid

go uuid

Last synced: about 9 hours ago
JSON representation

A wrapper for Linux kernel UUID v4 generator.

Awesome Lists containing this project

README

        

# go-uuid - A wrapper for Linux kernel UUID v4 generator.

[![Build Status][BuildStatus]](https://travis-ci.org/ybubnov/go-uuid)
[![Documentation][Documentation]](https://godoc.org/github.com/ybubnov/go-uuid)

This UUID library is an yet another attempt to reimplement the wheel, but
instead of outstanding algorithm it wraps the Linux kernel implementation
of UUID v4 generator.

## Installation

The latest version can be installed using ```go``` tool:
```sh
go get github.com/ybubnov/go-uuid
```

## Usage

### Trivial configuration
The usage is pretty straightforward. Here is the most trivial example:
```go
package main

import (
"fmt"

"github.com/ybubnov/go-uuid"
)

func main() {
u1 := uuid.New()
fmt.Printf("uuid v4: %s\n", u1)
}
```

### Advanced configuration
Another example shows an advanced configuration of generator. It defines the
```128``` buffered UUIDs, and 16 workers used to produce them.

```go
package main

import (
"fmt"

"github.com/ybubnov/go-uuid"
)

func main() {
src := uuid.Kernel{MaxIdle: 128, MaxProcs: 16}
defer src.Stop() // Terminate source when time comes.

u1, err := src.Next()
if err != nil {
fmt.Printf("failed to generate uuid: %s\n", err)
}

fmt.Printf("uuid v4: %s\n", u1)
}
```

## Licence

The UUID library is distributed under MIT license, therefore you are free to do
with code whatever you want. See the [LICENSE](LICENSE) file for full license text.

[BuildStatus]: https://travis-ci.org/ybubnov/go-uuid.svg?branch=master
[Documentation]: https://godoc.org/github.com/ybubnov/go-uuid?status.svg