Installing godi
godi is distributed as a Go module with zero runtime dependencies (besides the excellent dig which is bundled).
Requirements
Go 1.21 or later
A Go module (recommended)
Installation
Using Go Modules (Recommended)
Add godi to your project:
go get github.com/junioryono/godi
This will add godi to your go.mod file:
require github.com/junioryono/godi v1.x.x
Import in Your Code
import "github.com/junioryono/godi"
Verify Installation
Create a simple test file to verify the installation:
package main
import (
"fmt"
"github.com/junioryono/godi"
)
func main() {
collection := godi.NewServiceCollection()
fmt.Println("godi installed successfully!")
fmt.Printf("Collection type: %T\n", collection)
}
Run it:
go run main.go
Version Management
Check Current Version
go list -m github.com/junioryono/godi
Update to Latest
go get -u github.com/junioryono/godi
Use Specific Version
go get github.com/junioryono/godi@v1.x.x
Development Setup
If you want to contribute to godi:
# Clone the repository
git clone https://github.com/junioryono/godi.git
cd godi
# Install dependencies
go mod download
# Run tests
go test ./...
# Run tests with coverage
go test -cover ./...
Editor Support
godi works great with any Go development environment:
VS Code: Install the official Go extension
GoLand: Full support out of the box
Vim/Neovim: Use gopls for LSP support
Emacs: Use go-mode or lsp-mode
The type-safe generic helpers in godi provide excellent IDE support with auto-completion and type checking.
Next Steps
Read Why Dependency Injection? to understand the benefits
Follow the Getting Started Tutorial
Explore Core Concepts