Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example usage to README.md #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 42 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# uuid ![build status](https://travis-ci.org/google/uuid.svg?branch=master)
The uuid package generates and inspects UUIDs based on
[RFC 4122](http://tools.ietf.org/html/rfc4122)
and DCE 1.1: Authentication and Security Services.
and DCE 1.1: Authentication and Security Services.

This package is based on the github.com/pborman/uuid package (previously named
code.google.com/p/go-uuid). It differs from these earlier packages in that
Expand All @@ -11,9 +11,48 @@ change is the ability to represent an invalid UUID (vs a NIL UUID).
###### Install
`go get github.com/google/uuid`

###### Documentation
###### Example usage

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add the language type (in this case "go").

Suggested change
```
```go

package main

import (
"fmt"

"github.com/google/uuid"
)

func main() {

// uuid in uuid.UUID form
uid := uuid.New()
fmt.Println(uid)

// uuid v4 in a string form
uidStr := uuid.NewString()
fmt.Println(uidStr)

// urn version urn:uuid:xxx...
urnUuidStr := uuid.New().URN()
fmt.Println(urnUuidStr)

// Parse uuid
parsedUuid, err := uuid.Parse("138e62c7-1f88-42cb-8185-8d9e07918e84")

if err != nil {
fmt.Println(err)
} else {
fmt.Println(parsedUuid)
}

}

```


###### Documentation
[![GoDoc](https://godoc.org/github.com/google/uuid?status.svg)](http://godoc.org/github.com/google/uuid)

Full `go doc` style documentation for the package can be viewed online without
installing this package by using the GoDoc site here:
installing this package by using the GoDoc site here:
http://pkg.go.dev/github.com/google/uuid