checkGeoKey returns nil if we have a Google Geocoding API key file stored in the config dir. Otherwise it returns instruction about it as the error.
()
| 360 | // checkGeoKey returns nil if we have a Google Geocoding API key file stored |
| 361 | // in the config dir. Otherwise it returns instruction about it as the error. |
| 362 | func checkGeoKey() error { |
| 363 | if _, err := geocode.GetAPIKey(); err == nil { |
| 364 | return nil |
| 365 | } |
| 366 | keyPath, err := geocode.GetAPIKeyPath() |
| 367 | if err != nil { |
| 368 | return fmt.Errorf("error getting Geocoding API key path: %v", err) |
| 369 | } |
| 370 | if env.OnGCE() { |
| 371 | keyPath = strings.TrimPrefix(keyPath, "/gcs/") |
| 372 | return fmt.Errorf("using OpenStreetMap for location related requests. To use the Google Geocoding API, create a key (see https://developers.google.com/maps/documentation/geocoding/get-api-key ) and save it in your VM's configuration bucket as: %v", keyPath) |
| 373 | } |
| 374 | return fmt.Errorf("using OpenStreetMap for location related requests. To use the Google Geocoding API, create a key (see https://developers.google.com/maps/documentation/geocoding/get-api-key ) and save it in Perkeep's configuration directory as: %v", keyPath) |
| 375 | } |
| 376 | |
| 377 | func main() { |
| 378 | flag.Parse() |
no test coverage detected