8000 GitHub - squioc/axis: A golang library to manipulate generic dimensions (like time or distance)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

squioc/axis

Repository files navigation

Axis

A golang library to manipulate generic dimensions (like time or distance).

Inspired by timetools from mailgun.

Documentation:

The documentation is available at https://godoc.org/github.com/squioc/axis, thanks to GoDoc

Usage:

package main

import (
    "github.com/squioc/axis"
    "fmt"
    "time"
    "os"
)

func main() {
    provider := axis.NewFakeTime(2000)
    fmt.Println(provider.Current()) // 2000

    provider.Sleep(400) //Simulate a sleep
    fmt.Println(provider.Current()) // 2400

    C := make(chan int, 1)
    ch := provider.After(300)
    go func() {
        select {
            case position := <-ch:
                fmt.Println(position) // 2800
                C <- 1
            case <- time.After(time.Second):
                fmt.Fprintln(os.Stderr, "Timeout")
                C <- 1
        }
    } ()

    provider.Update(2800)
    <- C
}

About

A golang library to manipulate generic dimensions (like time or distance)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0