duration

package module
v0.0.0-...-63fffb1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: MIT Imports: 2 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Duration

Build Status

A wraper for time.Duration, for prettier print

Example

package main

import (
	"encoding/json"
	"fmt"

	duration "github.com/isayme/go-duration"
)

func main() {
	var d duration.Duration
	err := json.Unmarshal([]byte(`"1h2m3s"`), &d)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s\n", d.String()) // 1h2m3s
	fmt.Printf("%v\n", d)          // 1h2m3s
	fmt.Printf("%+v\n", d)         // 1h2m3s
	fmt.Printf("%#v\n", d)         // "1h2m3s"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Duration

type Duration time.Duration

Duration parse time.Duration from string

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration get time.Duration type value

func (Duration) GoString

func (d Duration) GoString() string

GoString for %#v

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

MarshalText ...

func (Duration) String

func (d Duration) String() string

String for %v

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) (err error)

UnmarshalText for json.Unmarshal

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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