uuid

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-lua-uuid

A GopherLua module for UUID generation and validation in Lua scripts.

Installation

go get github.com/kerimovok/go-lua-uuid

Usage

In Go
import (
    lua "github.com/yuin/gopher-lua"
    uuid "github.com/kerimovok/go-lua-uuid"
)

L := lua.NewState()
defer L.Close()

// Preload the uuid module
L.PreloadModule("uuid", uuid.Loader)

// Now Lua scripts can use require("uuid")
L.DoString(`
    local uuid = require("uuid")
    local id = uuid.new()
    print(id)
`)
In Lua
local uuid = require("uuid")

-- Generate a new UUID v4
local id = uuid.new()
print("Generated UUID:", id)

-- Alternative: use v4() function
local id2 = uuid.v4()
print("Another UUID:", id2)

-- Validate a UUID
local isValid = uuid.is_valid("550e8400-e29b-41d4-a716-446655440000")
if isValid then
    print("Valid UUID")
else
    print("Invalid UUID")
end

-- Parse and validate a UUID string
local parsed, err = uuid.parse("550e8400-e29b-41d4-a716-446655440000")
if err then
    error("Invalid UUID: " .. err)
end
print("Parsed UUID:", parsed)

Functions

uuid.new()

Generates a new UUID v4.

  • Returns:
    • string: UUID string in standard format (e.g., "550e8400-e29b-41d4-a716-446655440000")
uuid.v4()

Generates a new UUID v4 (alias for new()).

  • Returns:
    • string: UUID string
uuid.parse(str)

Parses and validates a UUID string.

  • Parameters:
    • str (string): UUID string to parse
  • Returns:
    • string: Parsed UUID string (or nil on error)
    • string (error): Error message if parsing fails
uuid.is_valid(str)

Checks if a string is a valid UUID.

  • Parameters:
    • str (string): String to validate
  • Returns:
    • boolean: true if valid UUID, false otherwise

Notes

  • All UUIDs generated are version 4 (random UUIDs)
  • UUID format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B
  • The module uses Google's UUID library for generation and validation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loader

func Loader(L *lua.LState) int

Loader loads the uuid module

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址