Socket
Book a DemoInstallSign in
Socket

github.com/financial-times/uuid-utils-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/financial-times/uuid-utils-go

v0.0.0-20210129100238-ad182dd851fc
Source
Go
Version published
Created
Source

uuid-utils-go

Circle CIGo Report Card Coverage Status

Introduction

This ia a library containing UUID generation and validation used in UPP's Golang services.

What methods should you use?

  • Generating an UUID based on another UUID: methods in deriveUUID.go

  • Generating an UUID from an random string (V3 version, i.e. using MD5 hashing): methods in generateV3UUID.go

  • Generating an UUID from an URL (V5 version, i.e. using SHA1 hashing): methods in generateV5UUID.go

  • Validating an UUID: methods in uuidValidation.go

Note: this library also contains methods that replicate java.util.UUID class (in uuid.go), for cases where it's already in use.

Installation:

  • Import the library (in your code):

     import (
             uuidutils "github.com/Financial-Times/uuid-utils-go"
     )
    
  • Vendor it (e.g. with govendor):

     govendor fetch github.com/Financial-Times/uuid-utils-go@1.0.0
     
    

Note1: this assumes your repo is already vendored (i.e. you ran: govendor init)

Note2: change in the fetch example above the appropriate tag release you want: @x.y.z

Usage examples:

  • Generating an UUID based on another UUID:

         originalUUID, _ := uuidutils.NewUUIDFromString("0000ea79-00a5-504e-a28d-11bd108b35ac")
         uuidDeriver := uuidutils.NewUUIDDeriverWith(uuidutils.IMAGE_SET)
    
         derivedUUID := uuidDeriver.From(originalUUID)
         
         revertToOriginalUUID := uuidDeriver.From(derivedUUID)
         
    
  • Generating an UUID from an random string (V3 version, i.e. using MD5 hashing):

         someString := "1AB23ad1x34"
         generatedUUID := uuidutils.NewV3UUID(someString)
    
  • Generating an UUID from an URL (V5 version, i.e. using SHA1 hashing):

         someString := "1AB23ad1x34"
         generatedUUID := uuidutils.NewDoubleDigestedV3UUID(someString)
    
  • Validating an UUID:

         someUUID := "0000ea79-00a5-504e-a28d-11bd108b35ac"
         err := ValidateUUID(validUUID)
         if err != nil {
             // do something with the error
         }
    

FAQs

Package last updated on 29 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.