MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / NewUUID

Function NewUUID

utils/operator.go:34–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34func NewUUID() string {
35 u := make([]byte, 16)
36 _, err := io.ReadFull(rand.Reader, u)
37 if err != nil {
38 return ""
39 }
40
41 // Set the version to 4 (randomly generated UUID)
42 u[6] = (u[6] & 0x0f) | 0x40
43 // Set the variant to RFC 4122
44 u[8] = (u[8] & 0x3f) | 0x80
45
46 return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x", u[0:4], u[4:6], u[6:8], u[8:10], u[10:])
47}
48
49func Ternary[T any](condition bool, trueValue, falseValue T) T {
50 if condition {

Callers 1

BuildElementMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected