utils

package
v0.0.0-...-6218f57 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadEnv

func LoadEnv(fileNames ...string)

Types

type CodeGenerationOutcome

type CodeGenerationOutcome int

The outcome of code generation.

const (
	NewLink CodeGenerationOutcome = iota
	ExistingLink
)

type CodeGenerationResult

type CodeGenerationResult struct {
	ShortCode string
	Result    CodeGenerationOutcome
	Err       error
}

The result of code generation.

func GenerateCode

func GenerateCode(url string, rdb *redis.Client) (*CodeGenerationResult, error)

GenerateCode generates a shortcode for the given URL. If the URL already has a shortcode, the existing shortcode is returned. If the URL does not have a shortcode, a new shortcode is generated and returned. If an error occurs, an empty string and an error are returned.

type DBError

type DBError string

Error when there is a database error

func (DBError) Error

func (e DBError) Error() string

type HashCollisionError

type HashCollisionError string

Error when there is a hash collision

func (HashCollisionError) Error

func (e HashCollisionError) Error() string

type InvalidURLError

type InvalidURLError string

Error when there is an invalid URL

func (InvalidURLError) Error

func (e InvalidURLError) Error() string

Jump to

Keyboard shortcuts

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