Datastar is single file on the front-end driven from the backend i.e. from golang. The php code you asked about contains construction of a full html page. I did not analyse the code why that's there, just saw it.
I mentioned the maintainer uses SQLite and NATS to bootstrap, but you don't need that. You can have a single golang file in your project, do the json serializing and any html if that is needed.