tizzy

package module
v0.0.0-...-306e376 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: BSD-3-Clause Imports: 6 Imported by: 2

README

Tizzy

Build Status GoDoc License

An in-memory copy of time.LoadLocation(), nothing original simply a workaround for when you find your code calling time.LoadLocation() at 1khz. This avoids opening a zip file on disk to unmarshal files containing bindata every call.

The timezone locations are loaded from $GOROOT/lib/time/zoneinfo.zip, the default for unix and windows.

Any copyrights belong to the Go authors.

Only supports go 1.10

Usage

    import "github.com/panamafrancis/tizzy"

    ...

    loc, err := tizzy.LoadLocation("Europe/Berlin")
    
    //or faster...
    
    locv, err := tizzy.LoadLocationValue("Europe/Berlin")

Benchmarks

On an early 2015 macbook pro, 2.9 GHz Intel Core i5, 16GB DDR3

go test -v -bench . -benchmem

...

goos: darwin
goarch: amd64
pkg: github.com/panamafrancis/tizzy
BenchmarkLoadLocationValue-4   	20000000	        82.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkLoadLocation-4        	10000000	       186 ns/op	      96 B/op	       1 allocs/op
BenchmarkTimeLoadLocation-4    	  100000	     14176 ns/op	    1922 B/op	      10 allocs/op

TODO

  • Support all operating systems, not just assume $GOROOT/lib/time/zoneinfo.zip exists.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadLocation

func LoadLocation(name string) (*time.Location, error)

LoadLocation returns the Location with the given name.

If the name is "" or "UTC", LoadLocation returns UTC. If the name is "Local", LoadLocation returns Local.

Otherwise, the name is taken to be a location name corresponding to a file in the IANA Time Zone database, such as "America/New_York".

func LoadLocationValue

func LoadLocationValue(name string) (time.Location, error)

LoadLocationValue avoids allocations on the heap.

Types

This section is empty.

Jump to

Keyboard shortcuts

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