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

research

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package research reads a project's research files, checks their format and substance, and summarizes them. The format is the one the lfm-research skill writes; the skill's own examples are tested against this parser.

Structure lives only in lines that start with a heading marker, a field marker or a table pipe. Quotes are blockquotes: every line starts with ">", so verbatim text may contain anything, including "#", "·" and URLs.

Index

Constants

View Source
const (
	RuleFormat    = "research.format"
	RuleSubstance = "research.substance"
	RuleBalance   = "research.balance"
)

Rule IDs reported by Check.

View Source
const (
	VoicesFile      = "human-voices.md"
	CompetitorsFile = "competitor-analysis.md"
)

Files inside the project's research directory.

View Source
const (
	MinVoices    = 60
	MinPlatforms = 5
	MinPeers     = 12
)

Minimums across all project research batches.

Variables

View Source
var (
	Authors = []string{"buyer", "adjacent", "creator", "brand", "expert"}
	Methods = []string{"connector", "fetch", "browser", "user"}
	// PeerFields are the facts recorded for every competitor, in order.
	PeerFields = []string{"Opening", "Palette", "Type", "Imagery", "Motion", "Mechanism", "Proof", "Price", "Tone", "Takeaway"}
)

Fixed vocabularies.

Functions

func Blockquote

func Blockquote(text string) string

Blockquote formats verbatim text as quote lines that parse back to exactly the same text: every line gets "> ", empty lines a bare ">".

func ParseCompetitors

func ParseCompetitors(text string) (Competitors, []Problem)

ParseCompetitors reads competitor-analysis.md.

func ParseVoices

func ParseVoices(text string) (Voices, []Problem)

ParseVoices reads human-voices.md. It never stops at a problem, so every defect in a file is reported at once.

func Rules

func Rules() []diagnostic.RuleInfo

Rules describes the research checks for the rule catalog.

Types

type Batch

type Batch struct {
	Line        int
	Date        time.Time
	Trigger     string // ongoing batches name what triggered them
	Queries     string
	Unreachable string
	Shortfall   string // why minimums are not met, when they are not
}

Batch is one dated research session.

type Competitors

type Competitors struct {
	Title    string
	Batches  []Batch
	Entries  []Peer
	Grid     []GridRow
	GridLine int
	Baseline string
	Gaps     []string
}

Competitors is competitor-analysis.md. Grid, Baseline and Gaps are those of the latest batch that has them.

type Count

type Count struct {
	Name string `json:"name"`
	N    int    `json:"voices"`
}

Count is a value with its frequency.

type GridRow

type GridRow struct {
	Line   int
	Column string
	Value  string
	Peers  int
}

GridRow is one value of one column and the number of peers showing it.

type Import added in v0.1.9

type Import struct {
	Date   time.Time
	Origin string
}

Import records when an item was copied and identifies its original source record.

type Peer

type Peer struct {
	Imported Import
	Line     int
	ID       int
	Name     string
	URL      string
	Fetched  time.Time
	Via      string
	Facts    map[string]string
	Batch    int
}

Peer is one competitor page.

type Precision

type Precision int

Precision is how exactly a source dates a post.

const (
	Unknown Precision = iota
	Year
	Month
	Day
)

type Problem

type Problem struct {
	Line    int
	Message string
	Hint    string
}

Problem is a format defect at a line of a research file.

type Report

type Report struct {
	Diagnostics []diagnostic.Diagnostic
	Summary     Summary
	Voices      *Voices      // nil when the file is absent
	Competitors *Competitors // nil when the file is absent
}

Report is the result of checking a project's research.

func Check

func Check(files map[string][]byte, dir string, today time.Time) Report

Check parses and checks the research files present in files (keyed by VoicesFile and CompetitorsFile; absent files are skipped). dir prefixes the file names in diagnostics; today bounds plausible dates.

type Summary

type Summary struct {
	Shortfalls []string  `json:"shortfalls,omitempty"`
	Voices     int       `json:"voices"`
	Peers      int       `json:"peers"`
	Batches    int       `json:"batches"`
	Platforms  []Count   `json:"platforms,omitempty"` // by voice count, largest first
	Dated      int       `json:"dated"`               // voices with a posted date
	Oldest     time.Time `json:"oldest,omitzero"`
	Newest     time.Time `json:"newest,omitzero"`
	Recent     int       `json:"recent"` // voices posted within a year of the latest fetch
	Latest     time.Time `json:"latestBatch,omitzero"`
}

Summary describes the research a page stands on.

func (Summary) Empty

func (s Summary) Empty() bool

Empty reports whether there is no research to describe.

type Voice

type Voice struct {
	Imported  Import
	Line      int
	ID        int
	Platform  string
	Place     string
	Author    string
	Posted    time.Time // start of the posted period; zero when the source shows no date
	Precision Precision
	Fetched   time.Time
	Via       string
	Quote     string
	URL       string
	Observer  string
	Batch     int // index into Voices.Batches
}

Voice is one verbatim quote.

type Voices

type Voices struct {
	Title   string
	Batches []Batch
	Entries []Voice
}

Voices is human-voices.md.

Jump to

Keyboard shortcuts

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