Skip to content

How to Generate a UUID V4 in Golang

Google has a package to generate a UUID compatible with RFC 4122 and DCE 1.1.

Add it to your project:

go get github.com/google/uuid

Generating UUIDs:

package main

import (
	"fmt"

	"github.com/google/uuid"
)

func main() {
	myUUID := uuid.New()

	fmt.Println(myUUID.String())
}

Leave a Reply

Your email address will not be published. Required fields are marked *