Base58-encoded UUID library for Go with zero dependencies.
go get github.com/b58uuid/b58uuid-gopackage main
import (
"fmt"
"log"
"github.com/b58uuid/b58uuid-go"
)
func main() {
// Generate a new UUID
b58, err := b58uuid.New()
if err != nil {
log.Fatal(err)
}
fmt.Println(b58) // Output: 3FfGK34vwMvVFDedyb2nkf
// Encode existing UUID
encoded, err := b58uuid.Encode("550e8400-e29b-41d4-a716-446655440000")
if err != nil {
log.Fatal(err)
}
fmt.Println(encoded) // Output: BWBeN28Vb7cMEx7Ym8AUzs
// Decode back to UUID
uuid, err := b58uuid.Decode("BWBeN28Vb7cMEx7Ym8AUzs")
if err != nil {
log.Fatal(err)
}
fmt.Println(uuid) // Output: 550e8400-e29b-41d4-a716-446655440000
}New() (string, error)- Generate a new random UUID and return Base58 encodingEncode(uuidStr string) (string, error)- Encode UUID string to Base58Decode(b58Str string) (string, error)- Decode Base58 string to UUIDMustEncode(uuidStr string) string- Encode UUID, panic on errorMustDecode(b58Str string) string- Decode Base58, panic on error
ErrInvalidUUID- Invalid UUID formatErrInvalidB58UUID- Invalid Base58 stringErrOverflow- Arithmetic overflow during conversion
- Zero dependencies (uses only Go standard library)
- Always produces exactly 22 characters
- Uses Bitcoin Base58 alphabet (no 0, O, I, l)
- Full error handling
- Thread-safe
go test -v ./...MIT License - see LICENSE file for details.