Documentation
¶
Overview ¶
Package exercise contains Advent of Code exercise management functionality.
Index ¶
- Constants
- Variables
- func NormalizationFactor() float64
- func ParseURL(url string) (int, int, error)
- func WithBenchmarkResultCallback(fn func(tasks.Result)) func(*Benchmarker)
- func WithBenchmarkWriter(w io.Writer) func(*Benchmarker)
- func WithDir(dir string) func(*Exercise)
- func WithDownloadLanguage(lang string) func(*Downloader)
- func WithExerciseDir(dir string) func(*Benchmarker)
- func WithInputFile(file string) func(*Exercise)
- func WithLanguage(lang string) func(*Exercise)
- func WithOverwrites(o *Overwrites) func(*Downloader)
- func WithResultCallback(fn func(tasks.Result)) func(*Exercise)
- func WithSkipImpl(skip bool) func(*Downloader)
- func WithURL(url string) func(*Downloader)
- func WithWriter(w io.Writer) func(*Exercise)
- type Answer
- type BenchmarkData
- type Benchmarker
- type Data
- type Downloader
- type Exercise
- type ImplementationData
- type Overwrites
- type PartData
- type Test
- type TestCase
Constants ¶
Variables ¶
var ( ErrEmptyLanguage = errors.New("no language specified") ErrNotFound = afero.ErrFileNotFound ErrNotImplemented = errors.New("not implemented") ErrNoRunner = errors.New("no runner available") ErrInvalidData = errors.New("invalid data") ErrNoImplementations = errors.New("no implementations found") ErrLoadInfo = errors.New("load info") )
var ( ErrNotConfigured = errors.New("not configured") ErrNilConfiguration = errors.New("nil configuration") ErrHTTPRequest = errors.New("http request") ErrHTTPResponse = errors.New("http response") ErrInvalidURL = errors.New("invalid URL") ErrInvalidLanguage = errors.New("invalid language") )
var ErrRunnerStart = errors.New("runner start error")
Functions ¶
func NormalizationFactor ¶
func NormalizationFactor() float64
func WithBenchmarkResultCallback ¶
func WithBenchmarkResultCallback(fn func(tasks.Result)) func(*Benchmarker)
func WithBenchmarkWriter ¶
func WithBenchmarkWriter(w io.Writer) func(*Benchmarker)
func WithDownloadLanguage ¶
func WithDownloadLanguage(lang string) func(*Downloader)
WithDownloadLanguage sets the language for the exercise implementation. This will override any language set in the configuration.
func WithExerciseDir ¶
func WithExerciseDir(dir string) func(*Benchmarker)
func WithInputFile ¶
func WithLanguage ¶
func WithOverwrites ¶
func WithOverwrites(o *Overwrites) func(*Downloader)
WithOverwrites sets the files that can be overwritten if already in place.
func WithResultCallback ¶
func WithSkipImpl ¶
func WithSkipImpl(skip bool) func(*Downloader)
WithSkipImpl sets the downloader to skip creating implementation files and structure.
func WithURL ¶
func WithURL(url string) func(*Downloader)
WithURL sets the exercise URL to download.
func WithWriter ¶
Types ¶
type BenchmarkData ¶
type BenchmarkData struct {
Date time.Time `json:"run-date"`
// Dir string `json:"dir"`
Title string `json:"title"`
Year int `json:"year,omitempty"`
Day int `json:"day"`
Runs int `json:"numRuns"`
Normalization float64 `json:"normalization,omitempty"`
Implementations []*ImplementationData `json:"implementations"`
}
func (*BenchmarkData) String ¶
func (b *BenchmarkData) String() string
type Benchmarker ¶
type Benchmarker struct {
*Exercise
// contains filtered or unexported fields
}
func NewBenchmarker ¶
func NewBenchmarker(cfg config.ExerciseConfiguration, options ...func(*Benchmarker)) (*Benchmarker, error)
type Data ¶
type Data struct {
InputData string `json:"-"`
InputFileName string `json:"inputFile"`
TestCases TestCase `json:"testCases"`
Answers Answer `json:"answers"`
}
Data contains the relative path to exercise input and the specific test case data for an exercise.
type Downloader ¶
type Downloader struct {
*Exercise
// contains filtered or unexported fields
}
func NewDownloader ¶
func NewDownloader(cfg config.DownloadConfiguration, options ...func(*Downloader)) (*Downloader, error)
func (*Downloader) Download ¶
func (d *Downloader) Download() error
func (*Downloader) FilePath ¶
func (d *Downloader) FilePath() string
type Exercise ¶
type Exercise struct {
ID string `json:"id"`
Title string `json:"title"`
Language string `json:"-"`
Year int `json:"year"`
Day int `json:"day"`
URL string `json:"url"`
Data *Data `json:"data"`
Path string `json:"-"`
// contains filtered or unexported fields
}
func New ¶
func New(cfg config.ExerciseConfiguration, options ...func(*Exercise)) (*Exercise, error)
func (*Exercise) Dir ¶
Dir returns the base of the exercise directory. It will return an empty string if the exercise does not exist.
Example: 01-someExerciseTitle.
func (*Exercise) GetImplementations ¶
GetImplementations returns a list of available implementations for the exercise.
type ImplementationData ¶
type ImplementationData struct {
Name string `json:"name"`
PartOne *PartData `json:"part-one"`
PartTwo *PartData `json:"part-two,omitempty"`
}
func (*ImplementationData) String ¶
func (i *ImplementationData) String() string
type Overwrites ¶
type Overwrites struct {
Input bool
}