Code Monkey home page Code Monkey logo

guid's Introduction

GoDoc

guid

The guid package implements a 16-byte guid/uuid type. It supports parsing of guid strings, validation of guids, and random generation of guids according to RFC-4122.

See http://godoc.org/github.com/beevik/guid for the godoc-formatted API documentation.

Example: Parsing a guid

g, err := guid.ParseString("67a23ff3-20be-4420-9274-d16f2833d595")

Example: Generating a random guid

g := guid.New()

Example: Validating a guid string

s0 := "67a23ff3-20be-4420-9274-d16f2833d595"
s1 := "67a23ff3-20be-4420-9274"
fmt.Println("s0 a guid?  ", guid.IsGuid(s0))
fmt.Println("s0 a guid?  ", guid.IsGuid(s1))

Output:

s0 a guid?  true
s1 a guid?  false

Example: Converting a guid to a string

for i := 0; i < 4; i++ {
	g := guid.New()
	fmt.Println("guid: %s  GUID: %s\n", g.String(), g.StringUpper())
}

Output:

guid: 9a5bb29c-cdcd-4b1b-a039-b88d1271ab4c  GUID: 9A5BB29C-CDCD-4B1B-A039-B88D1271AB4C
guid: efeeee74-aea6-4fa9-8037-8d3a3f883d3f  GUID: EFEEEE74-AEA6-4FA9-8037-8D3A3F883D3F
guid: 773730b7-7b5d-4ef0-80ed-f52617d5b688  GUID: 773730B7-7B5D-4EF0-80ED-F52617D5B688
guid: 256f523f-e65e-4451-9381-1d561abbc645  GUID: 256F523F-E65E-4451-9381-1D561ABBC645

guid's People

Contributors

beevik avatar beevikgist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.