### Go: Basic Dependency Injection without Sets Source: https://github.com/mazrean/kessoku/blob/main/examples/sets/README.md Demonstrates a basic dependency injection setup in Go using `kessoku.Inject` without utilizing `kessoku.Set` for grouping providers. It shows the direct provision of multiple dependencies. ```go var _ = kessoku.Inject[*App]( "InitializeAppBasic", kessoku.Provide(NewConfig), kessoku.Provide(NewDatabase), kessoku.Provide(NewUserService), kessoku.Provide(NewApp), ) ``` -------------------------------- ### Bash: Running the kessoku Sets Example Source: https://github.com/mazrean/kessoku/blob/main/examples/sets/README.md Provides the necessary bash commands to generate dependency injection code and run the kessoku sets example application. This is essential for testing the implemented dependency injection patterns. ```bash # Generate dependency injection code go generate ./examples/sets # Run the example go run ./examples/sets ``` -------------------------------- ### Go: Dependency Injection with Inline kessoku.Set Source: https://github.com/mazrean/kessoku/blob/main/examples/sets/README.md Illustrates using an inline `kessoku.Set` to group related providers directly within the `kessoku.Inject` call. This enhances organization by bundling configuration and database setup. ```go var _ = kessoku.Inject[*App]( "InitializeAppWithInlineSet", kessoku.Set( kessoku.Provide(NewConfig), kessoku.Provide(NewDatabase), ), kessoku.Provide(NewUserService), kessoku.Provide(NewApp), ) ``` -------------------------------- ### Install Kessoku CLI (Windows Binary) Source: https://github.com/mazrean/kessoku/blob/main/README.md Provides steps to download and install the Kessoku CLI binary for Windows systems. ```powershell # Download and install Invoke-WebRequest -Uri "https://github.com/mazrean/kessoku/releases/latest/download/kessoku_Windows_x86_64.zip" -OutFile "kessoku.zip" Expand-Archive -Path "kessoku.zip" -DestinationPath "." Move-Item "kessoku.exe" "$env:USERPROFILE\bin\" -Force # Add $env:USERPROFILE\bin to your PATH if not already added ``` -------------------------------- ### Parallel DI Example (Go) Source: https://github.com/mazrean/kessoku/blob/main/README.md Demonstrates how to use Kessoku for parallel dependency injection, contrasting it with sequential initialization. It shows how independent providers can run concurrently to reduce startup time. ```Go package main import ( "fmt" "time" "github.com/mazrean/kessoku" ) func SlowDB() string { time.Sleep(200 * time.Millisecond) return "DB-connected" } func SlowCache() string { time.Sleep(150 * time.Millisecond) return "Cache-ready" } //go:generate go tool kessoku $GOFILE var _ = kessoku.Inject[string]("InitApp", kessoku.Async(kessoku.Provide(SlowDB)), kessoku.Async(kessoku.Provide(SlowCache)), kessoku.Provide(func(db, cache string) string { return fmt.Sprintf("App running with %s and %s", db, cache) }), ) func main() { start := time.Now() result, _ := InitApp() fmt.Printf("%s in %v\n", result, time.Since(start)) } ``` -------------------------------- ### Install Kessoku CLI (Go Tool) Source: https://github.com/mazrean/kessoku/blob/main/README.md Instructions for installing the Kessoku command-line tool using the Go toolchain, which is required for code generation. ```bash go get -tool github.com/mazrean/kessoku/cmd/kessoku ``` -------------------------------- ### Install Kessoku CLI (Homebrew) Source: https://github.com/mazrean/kessoku/blob/main/README.md Instructions for installing the Kessoku CLI using Homebrew on macOS or Linux. ```bash brew install mazrean/tap/kessoku ``` -------------------------------- ### Install Kessoku CLI (Debian/Ubuntu) Source: https://github.com/mazrean/kessoku/blob/main/README.md Instructions for installing the Kessoku CLI on Debian or Ubuntu systems using a .deb package. ```bash wget https://github.com/mazrean/kessoku/releases/latest/download/kessoku_amd64.deb sudo apt install ./kessoku_amd64.deb ``` -------------------------------- ### Install Kessoku CLI (Linux/macOS Binary) Source: https://github.com/mazrean/kessoku/blob/main/README.md Provides steps to download and install the Kessoku CLI binary for Linux or macOS systems. ```bash # Download and install (replace with your platform) curl -L -o kessoku.tar.gz https://github.com/mazrean/kessoku/releases/latest/download/kessoku_Linux_x86_64.tar.gz tar -xzf kessoku.tar.gz sudo mv kessoku /usr/local/bin/ ``` -------------------------------- ### Go: Dependency Injection with Reusable Set Variables Source: https://github.com/mazrean/kessoku/blob/main/examples/sets/README.md Shows how to define reusable `kessoku.Set` variables for grouping providers, such as a `DatabaseSet`. This promotes reusability and cleaner code by abstracting common provider groups. ```go var DatabaseSet = kessoku.Set( kessoku.Provide(NewConfig), kessoku.Provide(NewDatabase), ) var _ = kessoku.Inject[*App]( "InitializeAppWithSetVariable", DatabaseSet, // Reuse the set kessoku.Provide(NewUserService), kessoku.Provide(NewApp), ) ``` -------------------------------- ### Go: Dependency Injection with Nested kessoku.Sets Source: https://github.com/mazrean/kessoku/blob/main/examples/sets/README.md Demonstrates the capability of nesting `kessoku.Set` instances within each other. This allows for hierarchical organization of providers, combining multiple sets into a single, comprehensive group. ```go var ServiceSet = kessoku.Set( DatabaseSet, // Include another set kessoku.Provide(NewUserService), ) var _ = kessoku.Inject[*App]( "InitializeAppWithNestedSets", ServiceSet, // This includes both database and service kessoku.Provide(NewApp), ) ``` -------------------------------- ### Install Kessoku CLI (Red Hat/CentOS/Fedora) Source: https://github.com/mazrean/kessoku/blob/main/README.md Instructions for installing the Kessoku CLI on Red Hat, CentOS, or Fedora systems using an .rpm package. ```bash wget https://github.com/mazrean/kessoku/releases/latest/download/kessoku_amd64.rpm # For CentOS/RHEL 7 and older sudo yum install ./kessoku_amd64.rpm ``` -------------------------------- ### Install Kessoku on Alpine Linux Source: https://github.com/mazrean/kessoku/blob/main/README.md Downloads the latest Kessoku release from GitHub and installs it using apk on Alpine Linux. The --allow-untrusted flag is used as the package is not signed. ```bash wget https://github.com/mazrean/kessoku/releases/latest/download/kessoku_amd64.apk sudo apk add --allow-untrusted kessoku_amd64.apk ``` -------------------------------- ### Install Kessoku on CentOS/RHEL/Fedora Source: https://github.com/mazrean/kessoku/blob/main/README.md Installs the Kessoku package using dnf on RPM-based Linux distributions like CentOS, RHEL 8+, and Fedora. This command assumes the RPM file is present in the current directory. ```bash sudo dnf install ./kessoku_amd64.rpm ``` -------------------------------- ### Testing and Formatting Source: https://github.com/mazrean/kessoku/blob/main/CLAUDE.md Essential commands for maintaining code quality. `go test` runs unit tests, and `go fmt` formats Go source files according to standard Go conventions. ```bash # Run tests go test -v ./... # Format code go fmt ./... ``` -------------------------------- ### Sequential vs Parallel Startup Comparison (Mermaid) Source: https://github.com/mazrean/kessoku/blob/main/README.md Visualizes the difference in application startup times between sequential and parallel dependency injection using a Mermaid Gantt chart. Highlights the time savings achieved with parallel execution. ```Mermaid gantt title Sequential vs Parallel Startup dateFormat X axisFormat %L section Sequential (slow) DB Service :0, 3 Cache Service :3, 5 Auth Service :5, 6 section Parallel (fast) DB Service :0, 3 Cache Service :0, 2 Auth Service :0, 1 ``` -------------------------------- ### Building and Code Generation Source: https://github.com/mazrean/kessoku/blob/main/CLAUDE.md Commands for building the Kessoku binary and generating dependency injection code. `go build` compiles the project, `go generate` runs code generation directives, and `go tool kessoku` directly invokes the tool. ```bash # Build the binary go build -o bin/kessoku ./cmd/kessoku # Generate dependency injection code using go generate go generate ./... # Generate dependency injection code directly go tool kessoku [files...] ``` -------------------------------- ### Kessoku Dependency Injection - Injector Declarations Source: https://github.com/mazrean/kessoku/blob/main/CLAUDE.md Shows how to declare dependencies for Kessoku using `kessoku.Inject` and `kessoku.Provide`. The `//go:generate` directive triggers code generation. ```go package main //go:generate go tool kessoku $GOFILE import "github.com/mazrean/kessoku" var _ = kessoku.Inject[*App]( "InitializeApp", kessoku.Provide(NewConfig), kessoku.Provide(NewDatabase), kessoku.Provide(NewUserService), kessoku.Provide(NewApp), ) ``` -------------------------------- ### Release Management Source: https://github.com/mazrean/kessoku/blob/main/CLAUDE.md Utilizes GoReleaser for managing project releases. It supports creating snapshot releases for local testing and full releases after tagging. ```bash # Create a snapshot release (local testing) go tool goreleaser release --snapshot --clean # Create a full release (requires git tag) git tag v1.0.0 go tool goreleaser release --clean ``` -------------------------------- ### Kessoku Dependency Injection - Provider Functions Source: https://github.com/mazrean/kessoku/blob/main/CLAUDE.md Demonstrates how to define provider functions in Go that return dependencies. These functions are used by Kessoku to generate injection code. ```go // NewDatabase creates a database connection. func NewDatabase(config *Config) (*Database, error) { // implementation } ``` -------------------------------- ### Linting Source: https://github.com/mazrean/kessoku/blob/main/CLAUDE.md Executes a comprehensive Go analyzer linter to identify potential code quality issues and enforce coding standards. ```bash # Run comprehensive Go analyzer linter go tool tools lint ./... ``` -------------------------------- ### Kessoku Go Library API Reference Source: https://github.com/mazrean/kessoku/blob/main/README.md Key functions and concepts for the Kessoku Go dependency injection library. It covers parallel execution, provider registration, value injection, and interface binding. ```APIDOC kessoku.Async(provider) - Description: Makes a provider run in parallel with other independent async providers. - Parameters: - provider: The function or value to be provided. kessoku.Provide(fn) - Description: Registers a regular provider that runs sequentially. - Parameters: - fn: The function to be provided. kessoku.Inject[T](name, ...) - Description: Generates the injector function for a specific type or name. - Parameters: - T: The type of the dependency to inject. - name: The name or identifier of the dependency. - ...: Other dependencies required by the injector. kessoku.Set(...) - Description: Groups multiple providers for reuse as a single unit. - Parameters: - ...: Providers to be grouped. kessoku.Value(val) - Description: Injects a constant value directly. - Parameters: - val: The constant value to inject. kessoku.Bind[Interface](impl) - Description: Binds an interface to its concrete implementation. - Parameters: - Interface: The interface type. - impl: The implementation of the interface. Rule: - Independent async providers run in parallel, dependent ones wait automatically. ``` -------------------------------- ### API Compatibility Checking Source: https://github.com/mazrean/kessoku/blob/main/CLAUDE.md Compares API compatibility between different versions of a Go package. It helps detect breaking changes by analyzing exported symbols. ```bash # Check API compatibility against a previous version go tool tools apicompat # Example: Check current changes against latest released version go tool tools apicompat github.com/mazrean/kessoku@latest github.com/mazrean/kessoku # Example: Check against a specific version go tool tools apicompat github.com/mazrean/kessoku@v1.0.0 github.com/mazrean/kessoku ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.