Go binding for libuuid

Related tags

Miscellaneous gouuid
Overview

Pure Go UUID implementation

This package provides immutable UUID structs and the functions NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 and 5 UUIDs as specified in RFC 4122.

Installation

Use the go tool:

$ go get github.com/nu7hatch/gouuid

Usage

See documentation and examples for more information.

Copyright

Copyright (C) 2011 by Krzysztof Kowalik [email protected]. See COPYING file for details.

Issues
  • Adds JSON marshalling support

    Adds JSON marshalling support

    I am using the gouuid library for the identifiers of my objects. These objects get stored in a document store and are exposed in a REST api. Both API and database marshal the object to the JSON format. Currently the uuid.UUID does not implement the json.Marshaller and json.Unmarshaller interface. This pull request changes that.

    I have added the MarshalJSON and UnmarshalJSON to the uuid.UUID type, which are covered by tests. The JSON value is a hex string as returned by the uuid.UUID.String method.

    opened by pjvds 5
  • Fixes to properly conform to the UUID standard for version 3, 4 and 5. Also included are improvements to readability and use.

    Fixes to properly conform to the UUID standard for version 3, 4 and 5. Also included are improvements to readability and use.

    • varient bits and type is now set correctly
    • varient bits and varient type can now be retrieved more efficiently
    • new tests added for variant setting
    • new tests added to confirm proper version setting
    • type UUID now conforms to the BinaryMarshaller and BinaryUnmarshaller interfaces
    • New was added to create a base UUID from a []byte
    • ParseHex was renamed to simply Parse
    • Parse creates a UUID and properly checks the string format
    • NewHex now performs unsafe creation of UUID from a hex string
    • NewV3 and NewV5 now take strings as a namespace name
    opened by twinj 4
  • Added uuid.Must()

    Added uuid.Must()

    Hello,

    I've added a Must() function to help while initializing variables. Inspired by text/template.

    I'm not sure how often a NewV4() produces an error, but from what I can see NewV5() never does. Please correct me if I'm wrong.

    uuid.Must() should be used with caution of course, as it forfeits the ability to handle an error.

    Thanks, Alex

    opened by alexkappa 3
  • Dont compile the regexp for every ParseHex call.

    Dont compile the regexp for every ParseHex call.

    The regexp object is threadsafe for use in multiple goroutines so it can be compiled during program init.

    Added a benchmark to test performance.

    Before: BenchmarkParseHex-4 500000 41549 ns/op 21190 B/op 115 allocs/op

    After: BenchmarkParseHex-4 5000000 4332 ns/op 336 B/op 6 allocs/op

    opened by Zariel 2
  • Json marshal as string

    Json marshal as string

    I've implemented json.Marshaler / Unmarshaler to serialize UUIDs to quoted strings.

    The first commit implements the features, the second is a refactor touching ParseHex to avoid an unnecessary allocation in the Unmarshal path.

    opened by aelse 1
  • Documentation cleanup

    Documentation cleanup

    Cleaned up the README to be in line with Go 1 installation conventions, added the examples to a test file so they will be tested with "go test" and show up in godoc.

    This also fixes issue #1.

    opened by kisielk 0
  • Bug in doc - byte array missing

    Bug in doc - byte array missing

    small bug in the docs.

           // generating v5 (or v3...)
        u5, _ := uuid.NewV5(uuid.NamespaceURL, "nu7hat.ch")
    

    needs to be

            // generating v5 (or v3...)
        u5, _ := uuid.NewV5(uuid.NamespaceURL,  []byte("nu7hat.ch"))
    
    opened by wlbr 0
  • Not compliant with RFC4122 spec

    Not compliant with RFC4122 spec

    The generated variant for nu7hatch uuids does not seem to be compliant with the RFC 4122 spec; this results in all nu7hatch uuids failing any RFC4122-based compliance/validation checks.

    Quoting the spec (from https://tools.ietf.org/html/rfc4122#section-4.1.1)

    4.1.1.  Variant
    ...
    
    Msb0  Msb1  Msb2  Description
    ...
        1     0     x    The variant specified in this document.
    ...
    

    Note though that the variant of nu7hatch uuids has these MSB bits set to 01, rather than 10; example code:

    package main
    
    import (
    	"fmt"
    
    	"github.com/nu7hatch/gouuid"
    )
    
    func main() {
    
    	// create a new v4 uuid
    	v4UUID, err := uuid.NewV4()
    	if err != nil {
    		panic(err.Error())
    	}
    
    	// RFC4122 states the variant format should be MSB0==1 and MSB1==0;
    	// https://tools.ietf.org/html/rfc4122#section-4.1.1
    	fmt.Printf("%08b\n", v4UUID.Variant())
    
    }
    
    

    Output: 01000000

    opened by rogerclermont 1
  • Go 1.10: uuid_test.go:50: Errorf format %d has arg err.Error() of wrong type string

    Go 1.10: uuid_test.go:50: Errorf format %d has arg err.Error() of wrong type string

    179d4d0c4d8d407a32af483c2354df1d2c91e6c3 does not pass unit tests with Go 1.10

    + GOPATH=/builddir/build/BUILD/gouuid-179d4d0c4d8d407a32af483c2354df1d2c91e6c3/_build:/usr/share/gocode
    + go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro  '\'''
    # github.com/nu7hatch/gouuid
    ./uuid_test.go:50: Errorf format %d has arg err.Error() of wrong type string
    ./uuid_test.go:98: Errorf format %d has arg err.Error() of wrong type string
    FAIL    github.com/nu7hatch/gouuid [build failed]
    
    opened by nim-nim 0
  • Changed HEX pattern.

    Changed HEX pattern.

    According to RFC and valid HEX characters, I suggest changing the word characters range to a-f only. Otherwise your previous pattern will match string like zzzzzzzz-zzzz-1zzz-zzzz-zzzzzzzzzzzz which is not a valid UUID.

    opened by shadyyx 0
  • nu7hatch/gouuid Duplicate sequentially generated V4 UUIDs

    nu7hatch/gouuid Duplicate sequentially generated V4 UUIDs

    README from fork https://github.com/jaytaylor/uuid:

    DEPRECATED DUE TO POOR RELIABILITY

    PLEASE DO DO NOT USE!

    This package is deprecated due to my having observed it generating duplicate UUID's in the wild from uuid.NewV4().

    Recommendation

    The current recommended UUID package for go is satori/go.uuid.

    Also, RE: nu7hatch

    If I could, I would also nuke nu7hatch/go-uuid from existence, as the core of this package is identical to it.

    opened by jaytaylor 5
  • Make the lib a bit more user friendly (methods on value)

    Make the lib a bit more user friendly (methods on value)

    • for the maintainer: fixes git lint warnings (about function's comments)
    • for the user: stop forcing Variant(), Version() and String() to be called on pointers

    The second commit (62f4d0c7b0891be66882636a7c09dc19e7487484) is more interesting: because these methods are defines on pointer, is it currently not possible to call them against a simple UUID value, even if nothing prevent to do so.

    opened by dohzya 0
Owner
Kris Kovalik
I'm not here, this is legacy profile. I'm at @0o153 now.
Kris Kovalik
A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Andrew Gallant 179 May 26, 2022
A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Andrew Gallant 179 May 26, 2022
mass-binding-target is a command line tool for generating binding target list by search plot files from disk.

mass-binding-target mass-binding-target is a command line tool for generating binding target list by search plot files from disk. Build Go 1.13 or new

null 0 Nov 5, 2021
A Go language binding for encodeing and decoding data in the bencode format that is used by the BitTorrent peer-to-peer file sharing protocol.

bencode-go A Go language binding for encoding and decoding data in the bencode format that is used by the BitTorrent peer-to-peer file sharing protoco

Jack Palevich 184 Jun 26, 2022
SDL2 binding for Go

SDL2 binding for Go go-sdl2 is SDL2 wrapped for Go users. It enables interoperability between Go and the SDL2 library which is written in C. That mean

Ve & Co. 1.8k Jun 21, 2022
Reflectionless data binding for Go's net/http (not actively maintained)

binding Reflectionless data binding for Go's net/http Features HTTP request data binding Data validation (custom and built-in) Error handling Benefits

Matt Holt 791 Jun 15, 2022
Go binding for the cairo graphics library

go-cairo Go binding for the cairo graphics library Based on Dethe Elza's version https://bitbucket.org/dethe/gocairo but significantly extended and up

Erik Unger 118 Apr 18, 2022
Go OpenCL (GOCL) Binding

gocl Go OpenCL (GOCL) Binding (http://www.gocl.org) Library documentation: http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ http://www.khron

Rain Liu 85 Jan 25, 2022
OpenGL binding generator for Go

GoGL GoGL is an OpenGL binding generator for Go. No external dependencies like GLEW are needed. Install the OpenGL bindings For example, OpenGL 2.1 bi

Christoph Schunk 139 Apr 26, 2022
Go binding for GTK

go-gtk WHATS Go bindings for GTK SCREENSHOT INSTALL You can experiment with go-gtk by running the various example programs: git clone https://github.c

mattn 1.9k Jun 28, 2022
The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.

Note that this project is largely unmaintained as I don't have the time to do or support more development. Please consider using this fork instead: ht

Andrew Gallant 444 Jun 18, 2022
Qt binding for Go (Golang) with support for Windows / macOS / Linux / FreeBSD / Android / iOS / Sailfish OS / Raspberry Pi / AsteroidOS / Ubuntu Touch / JavaScript / WebAssembly

Introduction Qt is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on var

null 9.3k Jun 27, 2022
Go binding to ImageMagick's MagickWand C API

Go Imagick Go Imagick is a Go bind to ImageMagick's MagickWand C API. We support two compatibility branches: master (tag v2.x.x): 6.9.1-7 <= ImageMagi

Go Graphics community 1.5k Jun 29, 2022
gin auto binding,grpc, and annotated route,gin 注解路由, grpc,自动参数绑定工具

中文文档 Automatic parameter binding base on go-gin doc Golang gin automatic parameter binding Support for RPC automatic mapping Support object registrati

xxj 226 Jun 30, 2022
Go binding for gammu

gogammu is binding for SMS related functions of libGammu (documentation). gogammu/smsd is simple, MySQL based, SMS daemon, written entirely in Go (it

Michał Derkacz 14 Dec 24, 2020
Iris Go binding

Iris Go binding This is the official Go language binding for the Iris cloud messaging framework. Version v1 of the binding is compatible with Iris v0.

Project Iris 134 Apr 22, 2022
Openldap (LDAP) binding for Golang (go) ; no more support ; you may have a look at https://github.com/go-ldap/ldap

OpenLDAP this is Openldap binding in GO language. I don't work any more with golang, so, please fork this project. Installation : Installation is easy

Marc Quinton 45 Mar 4, 2021
Cgo binding for icu4c library

About Cgo binding for icu4c C library detection and conversion functions. Guaranteed compatibility with version 50.1. Installation Installation consis

Dmitry Bondarenko 20 Jan 23, 2022
Cgo binding for Snowball C library

Description Snowball stemmer port (cgo wrapper) for Go. Provides word stem extraction functionality. For more detailed info see http://snowball.tartar

Dmitry Bondarenko 31 Feb 13, 2022
Go binding to libserialport for serial port functionality.

Go Serial Package serial provides a binding to libserialport for serial port functionality. Serial ports are commonly used with embedded systems, such

Jacob Michael Lee 51 Jun 15, 2022
Go binding for libshout 2.x

go-libshout (Incomplete but working) Go binding for libshout 2.x Example package main import ( "flag" "github.com/systemfreund/go-libshout" "os"

null 12 Dec 8, 2021
v8 javascript engine binding for golang

Go-V8 V8 JavaScript engine bindings for Go. Features Thread safe Thorough and careful testing Boolean, Number, String, Object, Array, Regexp, Function

Hoping White 200 Jun 9, 2022
golang curl(libcurl) binding.

go-curl my golang libcurl(curl) binding. See more examples in ./examples/ directory~! LICENSE go-curl is licensed under the Apache License, Version 2.

Andelf 428 Jun 18, 2022
Go binding for TensorFlow Lite

go-tflite Go binding for TensorFlow Lite Usage model := tflite.NewModelFromFile("sin_model.tflite") if model == nil { log.Fatal("cannot load model")

mattn 238 Jun 6, 2022
Simple QML binding for Go

Qamel Qamel is a simple QML binding for Go, heavily inspired by therecipe/qt. This package only binds Qt's classes that used for creating a simple QML

null 163 May 27, 2022
SDL2 binding for Go

SDL2 binding for Go go-sdl2 is SDL2 wrapped for Go users. It enables interoperability between Go and the SDL2 library which is written in C. That mean

Ve & Co. 1.8k Jun 26, 2022
Qt binding for Go (Golang) aims get Go's compile speed again.

qt.go Qt5 binding for Go (Golang) without CGO that aims to achieve Go's native compile speeds. Instead of using common bindings and heavy C++ wrapper

yatsen1 523 Jun 26, 2022
A Go skia binding based on skia C library through cgo

go-skia is a Go skia binding based on skia C library through cgo. Note: the project is still in early stage, and it only supports Linux-amd64 now. The

Go101 19 Mar 9, 2022
A Go idiomatic binding to the C++ core of PyTorch

GoTorch GoTorch reimplements PyTorch high-level APIs, including modules and functionals, in idiomatic Go. Thus enables deep learning programming in Go

Yi Wang 151 Jun 22, 2022