https://github.com/gone-io/gone
🚀 Gone - A Lightweight Dependency Injection Framework for Go | Tag-based Auto Injection | Supports Config Center/Lifecycle Management | Provides Rich Ecosystem Components and Scaffolding Tool
https://github.com/gone-io/gone
dependency-injection di dig golang gone gone-io goner wire
Last synced: 5 months ago
JSON representation
🚀 Gone - A Lightweight Dependency Injection Framework for Go | Tag-based Auto Injection | Supports Config Center/Lifecycle Management | Provides Rich Ecosystem Components and Scaffolding Tool
- Host: GitHub
- URL: https://github.com/gone-io/gone
- Owner: gone-io
- License: mit
- Created: 2022-10-16T03:27:08.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-04T03:44:19.000Z (6 months ago)
- Last Synced: 2025-06-04T10:27:50.626Z (6 months ago)
- Topics: dependency-injection, di, dig, golang, gone, gone-io, goner, wire
- Language: Go
- Homepage: https://goner.fun
- Size: 2.81 MB
- Stars: 129
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-cn - Gone - io/gone) [![包含中文文档][CN]](https://github.com/gone-io/gone) (Web框架 / 实用程序/Miscellaneous)
- awesome-go-plus - Gone - A lightweight dependency injection and web framework inspired by Spring.  (Web Frameworks / Utility/Miscellaneous)
- fucking-awesome-go - Gone - A lightweight dependency injection and web framework inspired by Spring. (Web Frameworks / Utility/Miscellaneous)
- awesome-go-with-stars - Gone - A lightweight dependency injection and web framework inspired by Spring. (Web Frameworks / Utility/Miscellaneous)
- awesome-go - gone-io/gone - A Lightweight Dependency Injection Framework for Go | Tag-based Auto Injection | Supports Config Center/Lifecycle Management | Provides Rich Ecosystem Components and Scaffolding Tool ☆`132` (Web Frameworks / Utility/Miscellaneous)
- awesome-go - Gone - A lightweight dependency injection and web framework inspired by Spring. (Web Frameworks / Utility/Miscellaneous)
- awesome-go - Gone - A lightweight dependency injection and web framework inspired by Spring. (Web Frameworks / Utility/Miscellaneous)
README
English  |  中文
[](LICENSE)
[](https://pkg.go.dev/github.com/gone-io/gone/v2)
[](https://goreportcard.com/report/github.com/gone-io/gone)
[](https://codecov.io/gh/gone-io/gone)
[](https://github.com/gone-io/gone/actions/workflows/go.yml)
[](https://github.com/gone-io/gone/releases)
[](https://github.com/avelino/awesome-go)

# 🚀 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):
```go
type Dep struct {
gone.Flag
Name string
}
type Component struct {
gone.Flag
dep *Dep `gone:"*"` //Dependency injection
log 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/goner
name string `gone:"config:name"`
}
func (c *Component) Init() {
c.log.Infof(c.dep.Name) //Use dependency
c.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)
- Configuration parameter injection (supports environment variables, config centers and config files)
- Third-party component injection (via Provider mechanism)
👉 [Detailed Documentation](docs/inject.md)
- 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](https://github.com/gone-io/goner) supporting configuration, logging, database, LLM, observability and more.
- Provides [scaffolding tool gonectl](https://github.com/gone-io/gonectl) supporting project creation, component management, code generation, test mocking, compilation and running.
### Architecture

## 🏁 Quick Start
### Environment Preparation
1. Install required tools
```bash
go install github.com/gone-io/gonectl@latest
go install go.uber.org/mock/mockgen@latest
```
### Create Project
```bash
gonectl create myproject
cd myproject
```
### Run Project
```bash
go mod tidy
gonectl run ./cmd/server
```
## More Documents
- 👉🏻 [docs](./docs)
- 👉🏻 [goner](https://github.com/gone-io/goner)
- 👉🏻 [gonectl](https://github.com/gone-io/gonectl)
## Release Notes
👉🏻 https://github.com/gone-io/gone/releases
## Contribution
If you find any bugs or have feature requests, feel free to [submit an issue](https://github.com/gone-io/gone/issues/new)
or [submit a pull request](https://github.com/gone-io/gone/pulls).
## Contact
If you have any questions, welcome to contact us through:
- [Github Discussions](https://github.com/gone-io/gone/discussions)
- Scan QR code to add WeChat, passcode: gone

## License
`gone` is released under the MIT License, see [LICENSE](./LICENSE) for details.