liveBook · Manning

Entity

As explained in Go in Action, Second Edition

An entity is a domain object representing a distinct business concept with identity and associated data or behavior.

An entity is a domain object representing a distinct business concept, such as an Article or Feed. It captures application-relevant data without depending on databases, HTTP frameworks, or other infrastructure. section 11.1.2

Use entities to establish the nouns and boundaries of a shared domain model:

  • Define only fields the application cares about, using portable standard-library types such as time.Time. section 11.1.2
  • Place the domain at the center so API and worker modules can share its vocabulary without tight coupling. section 11.1.2
  • Pair entity data with interfaces that describe required behavior while leaving implementations replaceable. section 11.1.2
Figure 11.3 Domain-driven design separates core logic from infrastructure.

The architecture diagram shows entities and interfaces at the domain center, with protocols and services depending inward. section 11.1.2

How Go in Action, Second Edition covers it

How deep it goes
Defines Article and Feed fields and relates them to interfaces, stopping short of detailed entity behavior or persistence.
Examples
Uses Article for news articles and Feed for RSS/Atom feeds, with Fetcher, ArticleReader, and Storage interfaces.
What you can do after
Build it from scratch by defining portable domain structs and interfaces before implementing API, worker, or infrastructure details.
How it connects
Connects entities with domain-driven design, interfaces, hexagonal architecture, API modules, and worker modules.

Also explained in

Compare how 12 books explain entity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Action, Second Edition. The section links point to the parts of the book it draws on.