Guide

Development

Building, testing and finding your way around the source tree. The toolchain is Go 1.27.0 and GNU Make; every task below has a Make target so CI and a laptop run the same command.

Setup and build

Prerequisites

  • Go 1.27.0, which is what go.mod declares and what CI, Docker and the snap build with. Go 1.27 rebuilt encoding/json on the v2 implementation, which roughly halves the time this program spends decoding the REST API — its single largest cost, measured at 637 µs → 322 µs for one page of a hundred posts.

    Worth knowing if you are weighing the same upgrade elsewhere: that speedup follows the toolchain, not the go line. A module declaring 1.26 and built with the 1.27 toolchain runs just as fast. This project declared 1.26.6 for one day for exactly that reason, because golangci-lint 2.12 could not analyse a module targeting 1.27 and panicked part-way through; 2.13.1 can, so the line moved up to say plainly what the project is built on.

  • Make

Setup

 1# Clone the repository
 2git clone https://github.com/tradik/wpexporter.git
 3cd wpexporter
 4
 5# Install dependencies
 6make deps
 7
 8# Install development tools
 9make dev-install
10
11# Run in development mode
12make dev

Building

1# Build for current platform
2make build
3
4# Build release binaries for all platforms
5make release

Testing

 1# Run tests
 2make test
 3
 4# Run linter
 5make lint
 6
 7# Run the security scanner
 8make sec
 9
10# Format code
11make format
12
13# Everything CI runs: vet, lint, gosec, tests
14make check

make sec builds gosec from the tools/ module rather than expecting it on PATH, so it is the same binary — and the same exclusion list — the pipeline uses. Nothing to install; the first run compiles it into build/.

Project structure

wpexporter/
├── cmd/
│   ├── wpexporter/          # umbrella command — export, xmlrpc, mcp
│   ├── wpexportjson/        # REST API exporter
│   ├── wpxmlrpc/            # XML-RPC exporter
│   └── wpmcp/               # MCP server
├── internal/
│   ├── api/                 # WordPress REST client
│   ├── xmlrpc/              # XML-RPC client
│   ├── mcp/                 # MCP protocol server, both eras (see docs/MCP.md)
│   ├── bruteforce/          # ID enumeration for unlisted content
│   ├── cli/                 # command wiring shared by the binaries
│   ├── config/              # configuration, CLI and file
│   ├── export/              # one exporter per output format
│   ├── media/               # media download and URL rewriting
│   ├── seo/                 # assisted crawl and metadata extraction
│   ├── flathtml/            # HTML to Markdown conversion
│   ├── basichtml/           # HTML reduction for store importers
│   ├── filter/              # content filters (paths, types)
│   ├── cache/               # HTTP response cache
│   ├── checkpoint/          # resume state
│   └── version/             # build stamp
├── pkg/
│   └── models/              # data models, the only exported package
├── docs/                    # the guides, published at wpexporter.tradik.com
├── templates/ssgtheme/      # the documentation site's theme
├── man/                     # man pages
├── tools/                   # separate module: gosec, pinned by tools/go.sum
├── Makefile                 # build automation
├── go.mod                   # Go module definition
└── README.md                # project overview