Zig
Zig
Generate UUID
See more ULID/UUID Examples
Generates a version 4 UUID, using either uppercase or lowercase hex.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const sb = try chilkat.StringBuilder.init();
defer sb.deinit();
// Generate a lowercase UUID.
var lowercase: bool = true;
sb.appendUuid(lowercase) catch {};
std.debug.print("{s}\n", .{try sb.getAsString(alloc)});
// example: edb1bb24-e9be-4ada-98bd-c2d893f29f55
lowercase = false;
sb.clear();
sb.appendUuid(lowercase) catch {};
std.debug.print("{s}\n", .{try sb.getAsString(alloc)});
// example: 338EAF28-631E-4303-BE27-A8D80E9191CB
}