0PricingLogin
Go Academy · Lesson

What Are Struct Tags

Attach metadata to fields.

What Are Struct Tags

A struct tag is a string of metadata attached to a struct field. It does not affect the field's value but carries instructions for libraries that read it.

Tag Syntax

Tags appear after the field type, wrapped in raw string quotes. Each tag is a key:"value" pair. Multiple pairs are space-separated.

A typical tag looks like json:"name".

All lessons in this course

  1. What Are Struct Tags
  2. JSON Tags
  3. Validation Libraries
  4. Custom Tag Parsing
← Back to Go Academy