A todo webapp written in go using htmx
and tailwindcss,
and Bootstrap 5
with sqlite
on the backend.
(I decided to go with Bootstrap instead of Tailwind right now
because I'm not that familiar with CSS and my focus is just a
UI that's good enough.)
- make sure app works by checking it with NerdCademy's template
- design web app layout on paper
- implement design with basic html no styles in particular
-
[ ] consider dockerizing backend part of app - consider trying to add new api route to allow for mobile or cli apps that connect to backend
- see how app plays under a proxy like nginx
- implement design with bootstrap
- make sure app looks good on desktop
- make sure app looks good on mobile
This method assumes you already have a compiled binary file on your machine and that you intend to deploy on some other machine.
Copy the binary file, the templates directoy, and the run.sh
script
into the app's directory on the remote machine.
A potential workflow could be:
# susbtitute $REMOTE_HOST for your ssh host and $APP_DIRECTORY for the folder
# you'll have this app run in on the server.
scp -r ./go-todo ./views ./run.sh $REMOTE_HOST:$APP_DIRECTORY
If you'd like to change the port that the app runs on,
you can modify it in run.sh
's environment variable.
You can just git clone this repo and run
CGO_ENGABLED=1 go build
.
You have to run it with the cgo
flag because the dependency
to allow for database interaction needs it to compile
(see the
installation section
of the go-sqlite3
for more details).
A potential workflow could be the below:
git clone https://github.com/vim-is-life/go-todo/
cd go-todo
CGO_ENABLED=1 go build .
You should then be able to run the app using run.sh
, modifying
the port it runs on as you desire.
Below are some of the resources I used in creating this app:
- Code from NerdCademy's webapp in go tutorial
- I kind of followed the structure of his code and used it as a loose reference for the code I wrote for my project
- HTML Templating With Go
- How to Use Templates in Go
- I used these as references for using templates in go, as I was not familiar with using templates.
- Using MVC to Structure Go Web Applications
- I used this article as a loose reference for ways to implement the MVC architecture in Go.
- http://go-database-sql.org/retrieving.html
- http://go-database-sql.org/modifying.html
- I used this reference to understand a bit more how to work with Go's database/sql package.
- Which Go router should I use? (with flowchart)
- I used this to understand why NerdCademy used
gorilla/mux
over thehttp.ServeMux
in the standard library, and to just learn more about the different available options for muxes in Go.
- I used this to understand why NerdCademy used
- Bootstrap5 Examples
- I used these examples to help with styling my app's HTML.