[BREAKGLASS] Modern Google Places CLI in Go
https://goplaces.sh/
| .github/workflows | ||
| cmd/goplaces | ||
| internal/cli | ||
| scripts | ||
| .gitignore | ||
| .golangci.yml | ||
| CHANGELOG.md | ||
| client_test.go | ||
| client.go | ||
| errors_test.go | ||
| errors.go | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
| types.go | ||
📍 goplaces - Find places, Go fast
Modern Go client + CLI for the Google Places API (New).
Features
- Text search with filters, location bias, and pagination.
- Place details by place ID.
- Resolve a free-form location string into candidates.
- Human-readable output with color, plus
--jsonfor scripts. - Strict validation + typed responses.
Install
go get github.com/steipete/goplaces
CLI
Set your API key via env or flag:
export GOOGLE_PLACES_API_KEY="..."
Search:
goplaces search "coffee" --min-rating 4 --open-now --limit 5 \
--lat 40.8065 --lng -73.9719 --radius-m 3000 --language en --region US
Details:
goplaces details ChIJN1t_tDeuEmsRUsoyG83frY4
Resolve:
goplaces resolve "Riverside Park, New York" --limit 5
JSON output:
goplaces search "pizza" --json
CLI reference
goplaces [--api-key=KEY] [--base-url=URL] [--timeout=10s] [--json] [--no-color] [--verbose]
<command>
Commands:
search Search places by text query.
details Fetch place details by place ID.
resolve Resolve a location string to candidate places.
Library
boolPtr := func(v bool) *bool { return &v }
floatPtr := func(v float64) *float64 { return &v }
client := goplaces.NewClient(goplaces.Options{
APIKey: os.Getenv("GOOGLE_PLACES_API_KEY"),
})
resp, err := client.Search(ctx, goplaces.SearchRequest{
Query: "italian restaurant",
Filters: &goplaces.Filters{
OpenNow: boolPtr(true),
MinRating: floatPtr(4.0),
Types: []string{"restaurant"},
},
LocationBias: &goplaces.LocationBias{Lat: 40.8065, Lng: -73.9719, RadiusM: 3000},
Limit: 10,
})
Notes
Filters.Typesmaps toincludedType(Google supports a single value). Only the first type is sent.- Price levels map to Google enums:
0(free) →4(very expensive). - Use
GOOGLE_PLACES_BASE_URLto override the endpoint (useful for tests). - Field masks are defined in
client.goconstants; extend them if you need more fields. - Google Places API usage is billed and quota-limited; keep an eye on your Cloud Console quotas.
Testing
go test ./... -coverprofile=coverage.out
Enforce coverage:
./scripts/check-coverage.sh