diff --git a/main.go b/main.go index a803c79..0841d3e 100644 --- a/main.go +++ b/main.go @@ -71,19 +71,21 @@ func main() { if result, err := c.Geocode(context.Background(), r); err != nil { log.Fatalf("fatal error: %s", err) } else { - l := location{ - Name: e.Name, - City: e.City, - Municipality: e.Municipality, - State: e.State, - Lat: result[0].Geometry.Location.Lat, - Long: result[0].Geometry.Location.Lng, - } - if response, err := json.Marshal(l); err != nil { - log.Fatalf("fatal error: %s", err) - } else { - if err := sc.Publish("DanceHall.Location", response); err != nil { + if len(result) > 0 { + l := location{ + Name: e.Name, + City: e.City, + Municipality: e.Municipality, + State: e.State, + Lat: result[0].Geometry.Location.Lat, + Long: result[0].Geometry.Location.Lng, + } + if response, err := json.Marshal(l); err != nil { log.Fatalf("fatal error: %s", err) + } else { + if err := sc.Publish("DanceHall.Location", response); err != nil { + log.Fatalf("fatal error: %s", err) + } } } }