If you accept that 1 day is 24 hours in some situations, you might want to parse it in Go too.

relaxduration

If you accept that 1 day is 24 hours in some situations, you might want to parse it in Go too.

This package tries to handle situations where durations were used without much care (e.g. 1 day is exactly 24 hours from now, 1 week is 168 hours from now, etc.) and you have to parse it in Go for some reason.

I decided to create it after reading this Golang Google Groups discussion and this issue. Since I searched, couldn't find one and, it took just some fun minutes, here we are.

Usage

Check example_duration_test.go, if it's not clear or you do not care about flags try something like:

package main

import (
	"github.com/jonathanbeber/relaxduration"
)

func main() {
	d, err := relaxduration.Parse("3 days 7 hours and 15 secs")
	if err != nil {
		println("unexpected: %v", err)
	}
	println(d.String())
	// Output: 79h0m15s
}
Owner
Jonathan Juares Beber
Software engineer. Working mainly with k8s, cloud and golang. Interests are way beyond it.
Jonathan Juares Beber
Similar Resources

Some helper types for go1: priority queue, slice wrapper.

go-villa Package villa contains some helper types for Go: priority queue, slice wrapper, binary-search, merge-sort. GoDoc Link: http://godoc.org/githu

Apr 24, 2021

Some gophers 🐻

Some gophers 🐻

Gophers 🐻 Hey 👋 ! Here are some drawings I have been using for talks about Golang. These are mainly gophers, but also some dukes, and miscellaneous.

Nov 15, 2022

dropspy is a (POC-quality) reworking of the C-language dropwatch tool in Go, with some extra features.

dropspy is a (POC-quality) reworking of the C-language dropwatch tool in Go, with some extra features.

Dec 12, 2022

Some examples of testing techniques and commonly used frameworks

golang-test-examples Some examples of testing techniques and commonly used frameworks Test frameworks Testify Ginkgo Convey godog (cucumber) Test exam

Oct 29, 2021

Some convenient string functions.

str Some convenient string functions. What This package containsa couple of functions to remove duplicates from string slices and optionally sort them

Dec 27, 2021

Some plain Go/Golang i2c sensor bindings to Waveshare Sense HAT for raspberry pi

i2c some plain Go/Golang i2c sensor bindings to Waveshare Sense HAT for raspberry pi using https://periph.io Supported hardware: Raspberry Zero W 1 ht

Dec 31, 2021

This contains some example (micro)service

This contains some example (micro)service. It should expose some of the issues when tyring to put too much logic into one file or to mix things that should not be mixed together.

Jan 11, 2022

In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

May 19, 2022

Assembly syntax that makes you feel like you're writing code in a high-level language.

shasm Assembly syntax that makes you feel like you're writing code in a high-level language. Shasm is not an Assembler. Shasm simply compiles Shasm sy

Jun 5, 2021
:chart_with_upwards_trend: Monitors Go MemStats + System stats such as Memory, Swap and CPU and sends via UDP anywhere you want for logging etc...

Package stats Package stats allows for gathering of statistics regarding your Go application and system it is running on and sent them via UDP to a se

Nov 10, 2022
Build for all Go-supported platforms by default, disable those which you don't want.

bagop Build for all Go-supported platforms by default, disable those which you don't want. Overview bagop is a simple build tool for Go which tries to

Jul 29, 2022
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar

Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star.

Dec 6, 2021
Day-1 is apart of my 6 days of Christmas challenge where i write in two new languages everyday, and make something weird out of it.

Day-1 is apart of my 6 days of Christmas challenge where i write in two new languages everyday, and make something weird out of it. today was a HTTP server written with PostGreSQL using Golang, R, and shell script read more

Dec 21, 2021
Year-end-review - enables those want to look back on PRs at the end of year to review PRs and the comments as single Markdown file.

year-end-review year-end-review enables those want to look back on PRs at the end of year to review PRs and the comments as single Markdown file. HOW

Dec 31, 2021
Parse Procfiles in go without yaml

procfile A go package for parsing Procfile entries. Install go get github.com/chrismytton/procfile Usage package main import ( "fmt" "github.com/c

Oct 19, 2022
Parse NYT crossword puzzle score screenshots and extract the times.

Parse NYT crossword puzzle score screenshots and extract the times.

Mar 11, 2022
Parse a shell script and output all export declarations in an easy to read format

Find Exports Parse a shell script and output all export declarations in an easy to read format. Usage Example $ findexports ~/.bashrc PATH=$PATH:/usr/

Jan 13, 2022
Some utilities for Persian language in Go (Golang)

persian Some utilities for Persian language in Go (Golang). Installation go get github.com/mavihq/persian API .ToPersianDigits Converts all English d

Oct 22, 2022
Functional programming library for Go including a lazy list implementation and some of the most usual functions.

functional A functional programming library including a lazy list implementation and some of the most usual functions. import FP "github.com/tcard/fun

May 21, 2022