Stacks

Go + PostgreSQL + PostGIS

Usecases

  • Find nearby merchants/stores
  • Find the nearby active drivers

Creating Table

CREATE TABLE IF NOT EXISTS places
(
id VARCHAR(36) NOT NULL PRIMARY KEY,
location GEOMETRY(POINT, 4326) NULL,
locations GEOMETRY(MULTIPOINT, 4326) NULL
);

Inserting Point

  • With raw query
INSERT INTO places (id, location)
VALUES (
'random-uuid',
ST_GeomFromText
('POINT(-71.060316 48.432044)', 4326)
);
lat, lon := -6.239967, 106.798443loc := ewkb.Point{Point: geom.NewPoint(geom.XY).SetSRID(4326).MustSetCoords(geom.Coord{
lat, lon,
})}
...db.Exec(`INSERT INTO places (id, locations) VALUES (?, ?);`, 'random-uuid', &loc)

--

--

1. On The Client (Implicit)
👍 only create an interface once the client need it
👍 no dead code on mock files

2. On The Provider (Explicit, Java Style)
👎 if the provider has a lot of methods, there must be a lot of unused interfaces and unused mock-methods as well on the client
👎 introducing a new interface/methods on the provider will force the client to upgrade the code as well, like implementing the new added method or regenerating the generated mock

--

--

  1. when the client failed to create http.NewRequest
  2. when the client got non-successful http.StatusCode
  3. when the client failed to read http.Response.Body
  4. when the client got an empty http.Response.Body
  5. when the client got an unmeet/broken response structure/contract
  6. when the client got an error/failed status response
  7. when the client got a fully successful response

--

--