liveBook · Manning

Exported field

As explained in Learn Go with Pocket-Sized Projects

An exposed field is a structure field whose visibility permits a template to access its value.

An exported field is a Go structure field whose visibility lets external mechanisms access its value. JSON decoding requires exported fields so the decoder can write into them; templates can read them with {{ .Field }}. section 3.1.3 section 11.6

Bookworm data structures

Bookworm, Books, Author, and Title are exported fields because their names begin with uppercase letters. JSON tags connect these fields to names such as name, books, author, and title, allowing encoding/json to populate the structures. section 3.1.3

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains visibility rules and demonstrates them through JSON structures and template field access.
Examples
Uses Bookworm and Book structures plus {{ .Field }} template access.
What it assumes
Assumes familiarity with Go structures and introduces visibility through JSON decoding and template access.
What you can do after
Apply it via encoding/json and Go templates to expose structure data safely to consumers.
How it connects
Connects Go structures with JSON tags, encoding/json, and Go templates.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.