Help us shape the future of Go! Take the 2026 Go Developer Survey

structured

package
v1.40.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package structured provides typed schema.org parsing from JSON-LD and HTML Microdata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Headline      *string
	Author        *string
	Description   *string
	DatePublished *string
	Image         *string
}

Article represents a schema.org Article/NewsArticle.

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data wraps parsed microdata with typed accessors.

func Parse

func Parse(r io.Reader, contentType, pageURL string) (*Data, error)

Parse extracts JSON-LD and Microdata from HTML.

func ParseNode added in v1.29.0

func ParseNode(root *html.Node, pageURL string) (*Data, error)

ParseNode extracts JSON-LD and Microdata from an ALREADY-PARSED HTML node tree, mirroring Parse but skipping its reader/html.Parse step. For a caller that already holds a parsed tree — e.g. extract.schemaPlaceCandidates, which reuses a *goquery.Document's own root node — this avoids a redundant serialize-back-to-string-then-reparse round trip over the same page. astappiev/microdata's own ParseHTML does exactly this internally (html.Parse then ParseNode), so this is the same walk, just fed a tree the caller already has.

func (*Data) FirstArticle

func (d *Data) FirstArticle() *Article

FirstArticle finds the first Article-like item.

func (*Data) FirstEvent

func (d *Data) FirstEvent() *Event

FirstEvent finds the first Event item.

func (*Data) FirstOrganization

func (d *Data) FirstOrganization() *Organization

FirstOrganization finds the first Organization item.

func (*Data) FirstPlace

func (d *Data) FirstPlace() *Place

FirstPlace finds the first Place-like item.

func (*Data) Places added in v1.4.1

func (d *Data) Places() []*Place

Places returns all Place entities found in structured data.

func (*Data) Raw

func (d *Data) Raw() *microdata.Microdata

Raw returns the underlying microdata for advanced use.

type Event

type Event struct {
	Name      *string
	StartDate *string
	EndDate   *string
	Location  *string
	Price     *string
}

Event represents a schema.org Event.

type Organization

type Organization struct {
	Name    *string
	URL     *string
	Phone   *string
	Address *string
	Hours   *string

	// LegalName is the schema.org legalName property when present — its presence
	// is itself a strong signal the Org block describes a registered legal entity.
	LegalName *string
	// HasLegalID reports whether a Russian legal-entity identifier
	// (ИНН/ОГРН/ОГРНИП/КПП) or its schema.org analogue (taxID/vatID) appears
	// anywhere in the Organization item -- as a property key, a property value, or
	// inside any nested item. Presence corroborates that the Org address is the
	// registered/legal seat.
	HasLegalID bool
}

Organization represents a schema.org Organization.

LegalName and HasLegalID are corroborant signals for the legal-address PROVENANCE arm (see extract.applyOrgFacts). An Organization itemtype CAN be the registered legal entity, but a bare Organization block whose streetAddress is in fact the venue's visiting address (no separate Place block, no legal identifiers) must NOT have that address demoted out of the map slot. These fields let the extract layer require a corroborating legal signal before treating the Org streetAddress as legal-by-provenance.

type Place

type Place struct {
	Name    *string
	Type    *string
	Address *string
	Phone   *string
	Website *string
	Hours   *string
	Price   *string
}

Place represents a schema.org Place/LocalBusiness.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL