GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - bethanyj28/gomato: A pomodoro timer written in Go.

BranchesTags
Open more actions menu

Latest commit

 

History

23 Commits
23 Commits

Folders and files

NameName
Last commit message
Last commit date
vendor
vendor
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
gomato.go
gomato.go
 
 
gomato_test.go
gomato_test.go
 
 

Repository files navigation

gomato

A pomodoro library written in Go.

Getting Started

You can initialize a timer in one of two ways:

  1. Using default settings

Default settings use the standard library log package and a cache with no expiration or cleanup.

pomodoro := gomato.NewDefaultTimeKeeper()
  1. Using custom settings

You can use your own standard log implementation and cache with custom cleanup. If you leave the cache nil, then it will create a cache with no expiration or cleanup. If you leave the logger nil, it will use a no-op logger.

import (
        "log"
        "time"

        gcache "github.com/patrickmn/go-cache"
        "github.com/bethanyj28/gomato"
)

logger := log.New(os.Stdout, "GOMATO: ", log.Lshortfile)
cache := gcache.New(5 * time.Minute, 5 * time.Minute)

pomodoro := gomato.NewTimeKeeper(logger, cache)

Starting a timer is simple:

pomodoro := gomato.NewDefaultTimeKeeper()
uID, err := pomodoro.Start("userID", 25 * time.Minute, action1(), action2())

The userID is optional. If you opt to not use your own, then one will be generated and returned. With StartWithTime you can optionally provide a starting time if it is not whatever time.Now() returns. If you enter a zero duration, it will be set to the typical 25 minutes that pomodoros are set. Actions are variadic, so you can enter as many or as few as you'd like, just make sure that there's nothing passed into them and they do not return anything. Feel free to look at the tests for an example on how to still pass in variables to the functions.

Pausing, Resuming, and Stopping simply require a userID.

Testing

For simple testing, this package abides by the following interface:

type PomodoroManager interface {
	StartWithTime(uID string, start time.Time, duration time.Duration, actions ...func()) (string, error)
	Start(uID string, duration time.Duration, actions ...func()) (string, error)
	Pause(uID string) error
	Resume(uID string) error
	Stop(uID string) error
}

Planned use cases

  • Slack App
  • CLI

About

A pomodoro timer written in Go.

Resources

Readme
Apache-2.0 license
Activity

Stars

0 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.