Knowledgebase

Building Services in Go Print

  • backenddevelopment, backend, database, errors, guide, howto, solution, zillionkinghost
  • 0

Practical development.

WHAT THE STANDARD LIBRARY PROVIDES

HTTP serving and routing JSON handling Templating Database access interfaces

WHAT THAT MEANS

A capable service can be built without any framework.

WHAT LIGHT FRAMEWORKS ADD

More expressive routing Middleware conveniences Binding and validation helpers

WHAT TO PREFER

The standard library, plus small focused packages.

WHY

Fewer dependencies, and the standard library is stable.

WHAT TO ALWAYS HANDLE

Every returned error.

WHAT NOT TO DO

Ignore errors to reduce verbosity.

WHAT TO USE FOR CANCELLATION AND TIMEOUTS

The context mechanism, passed through call chains.

WHY

It allows a cancelled request to stop work downstream immediately.

WHAT TO SET

Timeouts on the server, on clients, and on database operations.

WHAT TO BE CAREFUL WITH

Routines started and never terminated Shared data accessed concurrently without protection Unbounded concurrency

WHAT TO USE

The race detector, during testing.

WHAT TO BUILD FOR DEPLOYMENT

A static binary, with the version recorded.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot