runner

package
v0.0.0-...-2824937 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT, BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package runner provides a Runner type that is used to define both RunCounter and EmbeddedRunCounter to show examples of how to use composition in Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RunCounter

type RunCounter struct {
	// contains filtered or unexported fields
}

A RunCounter is a Runner that keeps a counter of the run tasks.

func NewRunCounter

func NewRunCounter(name string) *RunCounter

func (*RunCounter) Count

func (r *RunCounter) Count() int

func (*RunCounter) Name

func (r *RunCounter) Name() string

func (*RunCounter) Run

func (r *RunCounter) Run(t Task)

func (*RunCounter) RunAll

func (r *RunCounter) RunAll(ts []Task)

type RunCounter2

type RunCounter2 struct {
	Runner // HL
	// contains filtered or unexported fields
}

RunCounter2 is completely equivalent to RunCounter, but uses struct embedding to avoid the boilerplate of redeclaring the Name method.

func NewRunCounter2

func NewRunCounter2(name string) *RunCounter2

func (*RunCounter2) Count

func (r *RunCounter2) Count() int

func (*RunCounter2) Run

func (r *RunCounter2) Run(t Task)

func (*RunCounter2) RunAll

func (r *RunCounter2) RunAll(ts []Task)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

A Runner provides a way of running tasks.

func (*Runner) Name

func (r *Runner) Name() string

func (*Runner) Run

func (r *Runner) Run(t Task)

func (*Runner) RunAll

func (r *Runner) RunAll(ts []Task)

type Task

type Task struct{ Msg string }

A Task is a simple task that prints a message when run.

func (Task) Run

func (t Task) Run()

Jump to

Keyboard shortcuts

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