[BREAKGLASS] Modern Google Places CLI in Go https://goplaces.sh/
Go to file
2026-01-02 20:10:00 +01:00
.github/workflows feat: bootstrap goplaces 2026-01-02 17:21:02 +01:00
cmd/goplaces feat: bootstrap goplaces 2026-01-02 17:21:02 +01:00
internal/cli feat: add reviews support 2026-01-02 19:49:35 +01:00
scripts feat: bootstrap goplaces 2026-01-02 17:21:02 +01:00
.gitignore chore: fix lint config and docs 2026-01-02 17:35:00 +01:00
.golangci.yml chore: fix lint config and docs 2026-01-02 17:35:00 +01:00
CHANGELOG.md feat: add reviews support 2026-01-02 19:49:35 +01:00
client_test.go test: extend reviews coverage 2026-01-02 20:10:00 +01:00
client.go feat: add reviews support 2026-01-02 19:49:35 +01:00
e2e_test.go test: extend reviews coverage 2026-01-02 20:10:00 +01:00
errors_test.go feat: bootstrap goplaces 2026-01-02 17:21:02 +01:00
errors.go feat: bootstrap goplaces 2026-01-02 17:21:02 +01:00
go.mod feat: bootstrap goplaces 2026-01-02 17:21:02 +01:00
go.sum feat: bootstrap goplaces 2026-01-02 17:21:02 +01:00
LICENSE Initial commit 2026-01-02 16:49:23 +01:00
Makefile test: extend reviews coverage 2026-01-02 20:10:00 +01:00
README.md feat: add reviews support 2026-01-02 19:49:35 +01:00
types.go feat: add reviews support 2026-01-02 19:49:35 +01:00

📍 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 --json for 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 --reviews

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,
})

details, err := client.DetailsWithOptions(ctx, goplaces.DetailsRequest{
    PlaceID:        "ChIJN1t_tDeuEmsRUsoyG83frY4",
    Language:       "en",
    Region:         "US",
    IncludeReviews: true,
})

Notes

  • Filters.Types maps to includedType (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_URL to override the endpoint (useful for tests).
  • Reviews are returned only when IncludeReviews/--reviews is set.
  • Field masks are defined in client.go constants; 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

E2E tests (optional)

Real API tests (skipped unless you opt in):

export GOOGLE_PLACES_API_KEY="..."
go test -tags=e2e ./... -run TestE2E

Optional env overrides:

  • GOOGLE_PLACES_E2E_BASE_URL
  • GOOGLE_PLACES_E2E_QUERY
  • GOOGLE_PLACES_E2E_LANGUAGE
  • GOOGLE_PLACES_E2E_REGION