You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🚀 Gone - Lightweight Dependency Injection Framework for Go
💡 Framework Introduction
Gone is a lightweight dependency injection framework based on Golang tags, implementing component dependency management through concise annotations. Here is a typical usage example (a struct embedded with gone.Flag, which we call Goner):
typeDepstruct {
gone.FlagNamestring
}
typeComponentstruct {
gone.Flagdep*Dep`gone:"*"`//Dependency injectionlog gone.Logger`gone:"*"`//Inject gone.Logger// Inject configuration, get value from environment variable GONE_NAME; // if using components like goner/viper, values can be obtained from config // files or config centers.// Reference documentation: https://github.com/gone-io/gonernamestring`gone:"config:name"`
}
func (c*Component) Init() {
c.log.Infof(c.dep.Name) //Use dependencyc.log.Infof(c.name) //Use configuration
}
✨ Core Features
Comprehensive Dependency Injection Support
Struct field injection (supports private fields)
Function parameter injection (auto-matching by type)
Supports defining initialization methods, service start/stop methods and related lifecycle hook functions for Goners, enabling automated service management and custom operations.
Provides ecosystem goner components supporting configuration, logging, database, LLM, observability and more.
Provides scaffolding tool gonectl supporting project creation, component management, code generation, test mocking, compilation and running.
Architecture
🏁 Quick Start
Environment Preparation
Install required tools
go install github.com/gone-io/gonectl@latest
go install go.uber.org/mock/mockgen@latest