This project is a template to get you started with a golang + htmx + sqlite application.
The template follows my personal preferences when it comes to swagger generation, package organization, environment variables, and overall structure to make it easier to start new full stack project quickly.
- Install Golang.
go get -u ./...
to update all packages at once.go mod tidy
to fix package organization.- Create a sqlite database somewhere.
- Use "./SQL/foo_bars.sql" to add the schema to that db.
- Create "config.json" files in golang_api_lite and tests folders.
- Add more foo_bars records with tests.
go main.go
- More environments can be defined in Config.go if required (prod, test, dev, etc.)
- A config.json file should be created from example_config.json and added to the root project folder AND tests folder so tests run.
- Dockerfile is just a sample for a Golang app.
- Certs folder is where you store your .PEM files for encryption / authentication.
- You can swap out the sqlite connection for different db if you want.
- Architecture is based on using an embedded sqlite db, so keep that in mind, as it may not be the best use-case for what you want.
- I only listed a BasicAuth method because I wanted to keep this simple. Maybe in the future I'll add other auth schemes.
- PageHandlers probably isn't organized the best. Perhaps I could combine the route methods and the html file / templating code to create modular components. For now, the limited functionality is enough.
- I hate writing the swagger definitions by hand in JSON, but I also hate inline swagger comments even more. I also hate modifying existing, working code with swaggerest just to have explicit code-side swagger definitions. So for Golang, I haven't found an optimal solution. In light of all these annoying options, I decided to just use the raw JSON.
- I much prefer the styling of jsend wrapping every API request to randomness.
- I'm considering ripping out the gorm stuff and just hitting sqlite raw.