gosalusa.com

module
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT

README

Salusa

Coverage Go Reference

What is Salusa?

Salusa is a group of utilities to speed up web development in go. They can be used individually in existing projects or all together with the project template.

Packages

Dependancy Injection

The core of the Salusa framework is DI. It is used to get data into the http handlers and services you will create in a clean and consistent way.

Resources can be injected directly into Salusa http handlers.

type Request struct {
    DB *sqlx.DB `inject:""`
}
request.Handler(func(r *Request) (*Model, error) {
    return builder.From[*Model]().Find(r.DB, 1)
})

And services


type Service struct {
	Logger *slog.Logger `inject:""`
}

func (s *Service) Name() string {
	return "service-name"
}

func (s *Service) Run(ctx context.Context) error {
    s.Logger.Info("log message")
    return nil
}
Database - Builder

The database builder is used to create database queries. It uses a simple builder to make it easy to create dynamic queries.

model, err := builder.From[*your.Model]().Where("column", "=", "value").First(db)

Creating a Salusa Project

Before creating a salusa project you must have the go toolchain installed, instructions can be found here. You may also need node and npm to create frontends, they can be installed with the instructions found here.

After you have your environment set up you can install the spice utility with go:

go install gosalusa.com/spice@latest

Once you have installed spice you can create a new project with the init command:

spice init github.com/abibby/example-app

Once you have the created the app you can run the server with the dev command:

spice dev

After starting the development server you can access the application through you browser at http://localhost:2303.

Project Structure

root
├ app
│ ├ events
│ ├ handlers
│ ├ jobs
│ └ models
├ config
├ database
├ migrations
├ resources
└ routes

App

The app direcoty contains all of the buisness logic of your application. In a new project the only file in this directory is kernel.go which is the core of the application. The kernel manages all of the long running services in you application. You can find more information in the kernel docs

Events

The events directory contains all of the events that you application can emit.

Handlers

handlers contains all of the http handlers in your application. In a standard application they all implement the http.Handler interface. Salusa provides the request.Handler helper for creating APIs that speeds up handling user input and returning json. Documentation can be found here.

Jobs
Models

Directories

Path Synopsis
builder
Package builder provides a fluent, chainable query builder for the database package.
Package builder provides a fluent, chainable query builder for the database package.
dialects
Package dialects defines the query ASTs that describe SQL statements and the Dialect interface that renders them into RawQueries.
Package dialects defines the query ASTs that describe SQL statements and the Dialect interface that renders them into RawQueries.
dialects/generic
Package generic provides a database-agnostic implementation of the dialects.Dialect interface.
Package generic provides a database-agnostic implementation of the dialects.Dialect interface.
dialects/mysql
Package mysql implements the dialects.Dialect interface for MySQL.
Package mysql implements the dialects.Dialect interface for MySQL.
dialects/postgres
Package postgres implements the dialects.Dialect interface for PostgreSQL.
Package postgres implements the dialects.Dialect interface for PostgreSQL.
dialects/sqlite
Package sqlite implements the dialects.Dialect interface for SQLite.
Package sqlite implements the dialects.Dialect interface for SQLite.
model
Package model defines the types and helpers for persisting and loading database records through Go structs called models.
Package model defines the types and helpers for persisting and loading database records through Go structs called models.
schema
Package schema provides a dialect-agnostic DSL for describing and executing database schema changes such as creating, altering, and dropping tables.
Package schema provides a dialect-agnostic DSL for describing and executing database schema changes such as creating, altering, and dropping tables.
Package di provides a dependency injection container.
Package di provides a dependency injection container.
extra
internal
build command
cmd
pkg
template command
Package stream provides an immutable, lazy sequence abstraction that makes it easy to build and compose pipelines over slices and iterators.
Package stream provides an immutable, lazy sequence abstraction that makes it easy to build and compose pipelines over slices and iterators.
testing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL