github.com/weaviate/weaviate@v1.24.6/test/helper/uuid.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package helper
    13  
    14  import (
    15  	"encoding/binary"
    16  
    17  	"github.com/go-openapi/strfmt"
    18  	"github.com/google/uuid"
    19  )
    20  
    21  // InToUUID takes an unsigned int64 and places it in BigEndian fashion into the
    22  // upper 8 bytes of a 16 byte UUID. This makes it easy to produce easy-to-read
    23  // UUIDs in test scenarios. For example:
    24  //
    25  //	IntToUUID(1)
    26  //	// returns "00000000-0000-0000-0000-000000000001"
    27  func IntToUUID(in uint64) strfmt.UUID {
    28  	id := [16]byte{}
    29  	binary.BigEndian.PutUint64(id[8:16], in)
    30  	return strfmt.UUID(uuid.UUID(id).String())
    31  }