🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/evanoberholster/timezoneLookup

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/evanoberholster/timezoneLookup

v1.0.0
Source
Go
Version published
Created
Source

Timezone lookup library

This is a lookup API for GPS Coordinates to Timezone based on GeoJSON files.

  • Support added for MsgPack encoding for faster query.

Data

Data should be obtained via GeoJSON, I recommend: https://github.com/evansiroky/timezone-boundary-builder

Performance

 go run benchmark.go

Performance BoltDB

With Snappy Compression and data loaded from Boltdb

(Msgpack) Average time per query: ~18.015757ms

(Msgpack) Database file size: 89M

(Json) Average time per query: ~38.356527ms

(Json) Database file size: 70M

Alloc = 4 MiB	TotalAlloc = 232 MiB	Sys = 68 MiB	NumGC = 88

Performance Memory

With Snappy Compression and data loaded from memory

Average time per query: ~87.982µs

Database file size: 65M

Alloc = 550 MiB	TotalAlloc = 995 MiB	Sys = 601 MiB	NumGC = 10

Example

package main
import (
	"fmt"
	timezone "github.com/evanoberholster/timezoneLookup"
)
var tz timezone.TimezoneInterface

func main() {
	tz, err := timezone.LoadTimezones(timezone.Config{
											DatabaseType:"boltdb", // memory or boltdb
											DatabaseName:"timezone", // Name without suffix
											Snappy: true,
											Encoding: "msgpack", // json or msgpack
										})
	if err != nil {
		fmt.Println(err)
	}

	res, err := tz.Query(timezone.Coord{
			Lat: 5.261417, Lon: -3.925778,})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("Query Result: ", res)

	tz.Close()
}

FAQs

Package last updated on 19 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts