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 ¶
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
Click to show internal directories.
Click to hide internal directories.