Skip to content

nlittlepoole/go-whenami

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forthebadge forthebadge forthebadge

go-whenami

Go Report Card

go-whenami is a package that provides functionality to lookup the timezone of a given coordinate.

import (
    "log"
    "github.com/nlittlepoole/go-whenami"
)

func main(){
    lat := -77.0283 // float64
    long := 38.389 // float64
    timezone, err = whenami.WhenAmI(lat, long)
    if err != nil{
      log.Warn(err)
    }
}

Overview

This is a port of the Python project tzgeo. You can use this library to quickly associate a timezone with an (Latitude, Longitude) coordinate. In particular, this is helpful when parsing server or CDN logs that don't have timezone information but have coordinates provided via GeoIP.

What's Included

Server

I've included a small REST microservice built with the Gin framework. It exposes two endpoints. The first is a health check endpoint for scenarios where youy want to host this in a production system. The second is a /whenami/ GET endpoint that takes latitude and longitude as query parameters. It returns the timezone and any encountered errors.

Dockerfile

I've also created a Dockerfile that can be used to build spatialite and golang on top of Alpine. The container I've written also runs the server but feel free to rip any of that ode for another purpose.

Todo

  • Self host the tzgeo.sqlite file
  • Add tests
  • Create a base container for Spatialite + Golang on Alpine

About

Go Rest Microservice for finding timezone of a lat long

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages