mirror of
https://github.com/warmbly/warmbly.git
synced 2026-09-06 16:01:28 +00:00
Remove DynamoDB-backed storage paths, add Postgres/HTTP repositories for mailbox state maps, wire the internal message-map API, and add provisioning runner/migration plumbing.
31 lines
406 B
Go
31 lines
406 B
Go
package geo
|
|
|
|
import "github.com/oschwald/geoip2-golang/v2"
|
|
|
|
type Client struct {
|
|
r *geoip2.Reader
|
|
}
|
|
|
|
func New(location string) (*Client, error) {
|
|
if location == "" {
|
|
return &Client{
|
|
r: nil,
|
|
}, nil
|
|
}
|
|
db, err := geoip2.Open(location)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &Client{
|
|
r: db,
|
|
}, nil
|
|
}
|
|
|
|
func (c *Client) Close() {
|
|
if c == nil || c.r == nil {
|
|
return
|
|
}
|
|
_ = c.r.Close()
|
|
}
|