rid

package
v0.0.0-...-dfe2c77 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadMachineID

func ReadMachineID() []byte

ReadMachineID reads the machine ID from the environment variable or generates a random one.

func Salt

func Salt() uint64

Salt calculates the hash value of the machine ID and returns a salt value of type uint64.

Types

type ResourceID

type ResourceID string
Example
package main

import (
	"fmt"

	"github.com/MortalSC/MiniBlog/internal/pkg/rid"
)

func main() {
	userID := rid.UserID

	idString := userID.String()

	fmt.Println(idString)
}
Output:

user
const (
	// UserID is the resource ID for user
	UserID ResourceID = "user"
	// PostID is the resource ID for post
	PostID ResourceID = "post"
)

func (ResourceID) New

func (r ResourceID) New(counter uint64) string

New generates a new resource ID based on the given ID.

func (ResourceID) String

func (r ResourceID) String() string

String returns the string representation of the resource ID.

Jump to

Keyboard shortcuts

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