Giter Club home page Giter Club logo

emarifer / go-htmx-demo Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 6.0 83 KB

Simple full-stack web application for saving notes to a Sqlite database (CRUD), with HTML template rendering using </> htmx & _hyperscript. This is a minimalist application that does not use any additional libraries beyond the standard Go library.

License: MIT License

Go 48.21% CSS 12.45% JavaScript 1.17% HTML 38.16%
crud-application daisyui go golang htmx hyperscript sqlite3 tailwindcss template-engine template-engine-html

go-htmx-demo's Introduction

Golang Full-stack Web App

Simple full-stack web application for saving notes to a Sqlite database (CRUD), with HTML template rendering using </> htmx & _hyperscript.

This is a minimalist application that does not use any additional libraries beyond the standard Go library, except for the necessary driver to manage the Sqlite database, thus following the trend of Golang developers to only use dependencies strictly necessary, taking advantage of all the power of the standard library.

Rendering is achieved by using the "html/template" package, i.e. Go's native form of rendering, and the "</> htmx" JavaScript library. The latter makes it possible to make requests to the backend (GET, POST, PATCH and DELETE) without reloading the page as in a SPA, but with a size of said library of only 15K. Additionally, "_hyperscript" is used, another JavaScript library developed by the same author with the purpose of performing a few actions by writing a kind of inline JavaScript code.

Note: the theoretical bases of Htmx and illustrative examples of its correct use can be consulted in the book HYPERMEDIA SYSTEMS written by the same developer of the library, Carson Gross, in this site.

Screenshots:

Homepage:

Error reporting modal:

Setup:

Besides the obvious prerequisite of having Go! on your machine, you must have Air installed for hot reloading when editing code and NodeJs.

Since the application uses Tailwind as a CSS framework, you must run some NodeJs commands in the project root before starting the application:

$npm i

Next, whether you want to make code changes or create production CSS, you need to run these commands:

# If you want to edit the code and update the build CSS:

$npm run watch-css

# If you want to create the production CSS:

$npm run build-css-prod

Start the app in development mode:

$ air # Ctrl + C to stop the application

Build for production:

$ go build -ldflags="-s -w" -o ./bin/main . # ./bin/main to run the application

Happy coding ๐Ÿ˜€!!

go-htmx-demo's People

Contributors

emarifer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.