_055

package
v0.0.0-...-1f145c7 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package solution contains Solution to Challenge #055, run TestSolution for test cases

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStorageFull: error in case of full storage
	ErrStorageFull = errors.New("urlShortener: storage is full")
	// ErrNotFound: error in case id is not found in UrlShortener.Restore
	ErrNotFound = errors.New("urlShortener: request short url not found")
	// ErrUnsupportedAlgo: error in case of unsupported algorithm in UrlShortener.Shorten
	ErrUnsupportedAlgo = errors.New("urlShortener: provided algorithm not supported")
)

Functions

This section is empty.

Types

type GeneratorAlgo

type GeneratorAlgo int

GeneratorAlgo defines the type of generator

const (
	Randomize GeneratorAlgo = iota
	Sequential
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option: helps override default configurations to in memory UrlShortener

func SetGeneratorAlgorithm

func SetGeneratorAlgorithm(algo GeneratorAlgo) Option

func SetShortUrlSize

func SetShortUrlSize(n int64) Option

type UrlShortener

type UrlShortener interface {
	Shorten(url string) (string, error)
	Restore(id string) (string, error)
}

UrlShortener: provides the interface for any url shortener

func NewUrlShortener

func NewUrlShortener(opts ...Option) UrlShortener

NewUrlShortener returns an in memory UrlShortener, using Randomize with size 6 use options to override them

Jump to

Keyboard shortcuts

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