Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lu4p/go-template-turbo-sample
https://github.com/lu4p/go-template-turbo-sample
Last synced: 30 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/lu4p/go-template-turbo-sample
- Owner: lu4p
- License: unlicense
- Created: 2020-12-30T01:50:40.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-11T13:16:14.000Z (over 3 years ago)
- Last Synced: 2024-06-21T16:57:40.532Z (5 months ago)
- Language: Go
- Size: 208 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-template-turbo-sample
This is a sample project to show how to use Go (templates) with Turbo.This project uses:
- [Go](https://golang.org/), a programming language that makes it easy to build simple, reliable, and efficient software.
- [html/template](https://pkg.go.dev/html/template), a html templating library included in the stdlib of Go
- [Echo](https://echo.labstack.com/), a Go web framework
- [Turbo](https://turbo.hotwire.dev/), part of [Hotwire](https://hotwire.dev/) a new approach from Basecamp for writing modern web applications without much JavaScript
- [tailwindcss](https://tailwindcss.com/), makes HTML look nice
- [webpack](https://webpack.js.org/), for packing JS and CSS into single files, with minimization enabled, setup to extract CSS to a seperate file
- [Air](https://github.com/cosmtrek/air), for hot reloading Go code and templates on change.## Setup
You need to have [go](https://golang.org/dl/) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) installed.Then run:
```sh
go get -u github.com/cosmtrek/air
git clone https://github.com/lu4p/go-template-turbo-sample.git
cd templates-turbo-sample
npm install
npm run dev
```After the above just run `air`, to start the webapp with hot reloading.
**Note:** The generated `dist/main.css` file is rather large now at ~6MB, but don't worry this is only because every possible class of tailwind is included (there a many), once you build for production only ~4KB of CSS is left.
If you want to also rebuild the JS and CSS on change run `npm run watch` in a separate terminal session.
To build for production run `npm run prod` and `go build`.