component

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package component provides GORM SQLite lifecycle integration for bootstrap.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Component

func Component() bootstrap.IComponent

The SQLite path is read from env key db.sqlite.path during Init(). Typical values:

  • "file:app.db?cache=shared" for file-based databases
  • "file::memory:?cache=shared" for in-memory databases (tests)
Example

ExampleComponent shows how Component() is used in a bootstrap registration chain. It reads the SQLite path from env key db.sqlite.path during Init():

"file:app.db?cache=shared"          — file-based database
"file::memory:?cache=shared"        — in-memory (tests, ephemeral data)

SQLite is an embedded database — Init() never fails due to network issues. Schema migration should be registered as a PreReady step immediately after:

bootstrap.New().
    Add(envComp.Component(...)).
    Add(logComp.Component()).
    Add(dbComp.Component()).
    PreReady(func() error {
        return dbgorm.AutoMigrate(ctx, dbgorm.Default(), dbgorm.MigrateOptions{Enabled: true}, &MyModel{})
    }).
    Run()
package main

import (
	"fmt"

	dbComp "github.com/phcp-tech/common-library-golang/dbgorm/sqlite/component"
)

func main() {
	c := dbComp.Component()
	fmt.Println(c != nil)
}
Output:
true

Types

This section is empty.

Jump to

Keyboard shortcuts

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