Giter VIP home page Giter VIP logo

go-template's Introduction

Go web server template

Author: @nexovec

Uses: APIs, glorious monolith applications, high performance HTTP

This is my personal HTTP server template. Since I'm responsible for making more than one project with a common structure, a template is a nice to have

BONUS: this is available as open source.

Prerequisites

You need to have go 1.22 and docker installed. Primarily, only linux is supported. Recommended vs code extensions are: Git lens, go nightly, error lens, intellicode, templ lsp. Additionally, installation of graphviz is recommended.

Usage

TODO: move things from air.toml pre_cmd into here to speed up builds

You can launch the project with docker compose up --build.

You should run templ generate --watch to watch for changes to template directories.


You might need to run go work sync && go work vendor as sudo when adding new packages.

You can run sqlc generate --file configs/sqlc.yml to generate accessor functions for new SQL commands in internal/moels/queries

you can uncomment the command in configs/air.toml to get "hot-reload" (but it's quite slow).

You might need to run pnpm install to get tools to be able to build client-side css and javascript.

The tech

Postgres

This specifically uses postgres for its good sqlc support, lots of available extensions and libraries, and its popularity. SQLite should be considered for simple CRUD apps.

ORM & Migrations

We use basic go migrate for db migrations. We don't use ORMs, but we use sqlc to generate access methods for raw SQL queries.

Caching

We use the in-memory cache Otter for its excellent performance and simple API.

Server tech

Framework of choice is go fiber, for excellent performance and simple API.

We use lodash for go to suplement what we don't have in the stdlib, this has the added benefit of being similar to javascripts equivalent.

Air is in charge of hot-reloading.

go-template's People

Contributors

nexovec avatar

Stargazers

Tomáš Kroupa avatar  avatar

Watchers

 avatar

go-template's Issues

[jspacker] add js library management package

I have a library for deciding which script and links to ship with HTML with full support for versioning, CDNs with fallback configured with one config file lying on the side, and I'd like to intergate it into this project.

add custom rate limiter

I am writing a rate limiter middleware on the side. I'd like it to become a separate open source package and then use it here, because it's on-topic.

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.