Coder Social home page Coder Social logo

uuid's Introduction

uuid

Package uuid implements UUID RFC 4122.

Usage

Generating

Time-Based (Version 1)

uuid.NewTimeBased() (uuid.UUID, error)
uuid.NewV1() (uuid.UUID, error)

DCE Security (Version 2)

uuid.NewDCESecurity(uuid.Domain) (uuid.UUID, error)
uuid.NewV2(uuid.Domain) (uuid.UUID, error)

Name-Based uses MD5 hashing (Version 3)

uuid.NewNameBasedMD5(namespace, name string) (uuid.UUID, error)
uuid.NewV3(namespace, name string) (uuid.UUID, error)

Random (Version 4)

uuid.NewRandom() (uuid.UUID, error)
uuid.NewV4() (uuid.UUID, error)

Name-Based uses SHA-1 hashing (Version 5)

uuid.NewNameBasedSHA1(namespace, name string) (uuid.UUID, error)
uuid.NewV5(namespace, name string) (uuid.UUID, error)

Styles

  • Standard: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12, length: 36)
  • Without Dash: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (length: 32)

Formatting & Parsing

uuid.UUID.String() string                        // format to standard style
uuid.UUID.Format(uuid.Style) string              // format to uuid.StyleStandard or uuid.StyleWithoutDash

uuid.Parse(string) (uuid.UUID, error)       // parse from UUID string

uuid's People

Contributors

sean- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

uuid's Issues

Case-sensitivity in imports...

Can you please rename the org to be golang-plus instead of Golang-Plus? The mixed case between the github repo and the imports is problematic:

$ go get -v -u github.com/Golang-Plus/uuid
github.com/Golang-Plus/uuid (download)
github.com/golang-plus/errors (download)
github.com/golang-plus/uuid (download)
Golang-Plus/uuid/layout.go:4:2: use of internal package not allowed
Golang-Plus/uuid/domain.go:4:2: use of internal package not allowed
Golang-Plus/uuid/namespace.go:4:2: use of internal package not allowed
Golang-Plus/uuid/uuid.go:9:2: use of internal package not allowed
Golang-Plus/uuid/uuid.go:10:2: use of internal package not allowed
Golang-Plus/uuid/uuid.go:11:2: use of internal package not allowed
Golang-Plus/uuid/uuid.go:12:2: use of internal package not allowed
Exit 1
$ rm -rf $GOPATH/src/github.com/Golang-Plus/uuid
$ go get -v -u github.com/golang-plus/uuid
github.com/golang-plus/uuid (download)
github.com/golang-plus/errors (download)
github.com/golang-plus/uuid/internal
github.com/golang-plus/uuid/internal/namebased
github.com/golang-plus/errors
github.com/golang-plus/uuid/internal/timebased
github.com/golang-plus/uuid/internal/namebased/md5
github.com/golang-plus/uuid/internal/random
github.com/golang-plus/uuid/internal/namebased/sha1
github.com/golang-plus/uuid/internal/dcesecurity
github.com/golang-plus/uuid
$ cd $GOPATH/src/github.com/golang-plus/uuid/
$ go list ./...
github.com/golang-plus/uuid
github.com/golang-plus/uuid/internal
github.com/golang-plus/uuid/internal/dcesecurity
github.com/golang-plus/uuid/internal/namebased
github.com/golang-plus/uuid/internal/namebased/md5
github.com/golang-plus/uuid/internal/namebased/sha1
github.com/golang-plus/uuid/internal/random
github.com/golang-plus/uuid/internal/timebased
$ egrep -r Golang-Plus .
Exit 1
$ egrep -r golang-plus *
domain.go:	"github.com/golang-plus/uuid/internal/dcesecurity"
internal/dcesecurity/dcesecurity.go:	"github.com/golang-plus/uuid/internal"
internal/dcesecurity/dcesecurity.go:	"github.com/golang-plus/uuid/internal/timebased"
internal/dcesecurity/dcesecurity.go:	"github.com/golang-plus/errors"
internal/namebased/md5/md5.go:	"github.com/golang-plus/uuid/internal"
internal/namebased/md5/md5.go:	"github.com/golang-plus/errors"
internal/namebased/sha1/sha1.go:	"github.com/golang-plus/uuid/internal"
internal/namebased/sha1/sha1.go:	"github.com/golang-plus/errors"
internal/random/random.go:	"github.com/golang-plus/uuid/internal"
internal/random/random.go:	"github.com/golang-plus/errors"
internal/timebased/timebased.go:	"github.com/golang-plus/uuid/internal"
internal/timebased/timebased.go:	"github.com/golang-plus/errors"
layout.go:	"github.com/golang-plus/uuid/internal"
namespace.go:	"github.com/golang-plus/uuid/internal/namebased"
parse.go:	"github.com/golang-plus/errors"
parse_test.go:	testing2 "github.com/golang-plus/testing"
uuid.go:	"github.com/golang-plus/uuid/internal"
uuid.go:	"github.com/golang-plus/uuid/internal/dcesecurity"
uuid.go:	"github.com/golang-plus/uuid/internal/namebased/md5"
uuid.go:	"github.com/golang-plus/uuid/internal/namebased/sha1"
uuid.go:	"github.com/golang-plus/uuid/internal/random"
uuid.go:	"github.com/golang-plus/uuid/internal/timebased"
version.go:	"github.com/golang-plus/uuid/internal"

This can only be fixed by the project maintainer renaming the organization from Golang-Plus to golang-plus.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.