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

mariadb

command
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

README

mariadb example

A second reference host application, running the CMS on MariaDB instead of Postgres.

Where examples/basic is the full setup — Tailwind, the media library, a login CAPTCHA, blog & news, a custom admin section — this one is the opposite: the smallest host that does something real. No build step, no Node, no object store. The stylesheet is a <style> block in templates/base.gohtml.

Run it

docker compose up -d     # MariaDB on localhost:3309
go run .

Then open http://localhost:4200/admin/ and log in with admin@example.com, with the password the first run generates and logs (set CMS_ADMIN_PASSWORD to choose your own).

There is no content yet: create a page from Pages → New, leaving the slug empty to make it the homepage. Then visit /, click Edit in the bar at the bottom, and change the text in place.

To start over with an empty database:

docker compose rm -sfv mariadb && docker compose up -d

What this example shows

MariaDB needs four DSN settings. They are in defaultDSN in main.go, each with a comment explaining what breaks without it. The one that bites hardest is clientFoundRows=true: without it MySQL and MariaDB report rows changed rather than rows matched, so re-saving a record with unchanged values looks to the CMS like "no such row" and the save fails.

Config.Dialect must be set explicitly. database/sql does not expose which driver a pool was opened with, so the CMS cannot detect it. "mysql" covers MariaDB too — they share one dialect.

A host without Tailwind owns its own classes. The built-in SectionStyles and EditorStyles are Tailwind class names, which render as nothing here. main.go overrides both with class names that templates/base.gohtml defines. Worth knowing when you write your own:

Field Where it lands
Background Class the <section> wrapper
Background ContentClass the inner <div> (this is how the built-in dark and accent backgrounds add prose-invert)
Corner Class the <section> wrapper, so the radius clips the background
Width Class the inner <div>
Width ContentClass unused

Ports

Chosen so every example can run at the same time:

Postgres MySQL MariaDB App
examples/basic 5433 3307 3308 4000
examples/mariadb — — 3309 4200

Documentation

Overview

Command mariadb is a second reference host application for the CMS, running on MariaDB instead of Postgres.

It is deliberately the plainest possible host: hand-written CSS in the layout, no Tailwind, no build step, no object store. Start the database and run it —

docker compose up -d
go run .

— then open http://localhost:4200/admin/ and log in with admin@example.com, with a password generated and logged on the first run.

See examples/basic for the fuller setup: Tailwind, the media library, a login CAPTCHA, and a custom admin section.

Jump to

Keyboard shortcuts

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