Skip to content
/ gone Public

πŸš€ Gone - A Lightweight Dependency Injection Framework for Go | Tag-based Auto Injection | Supports Config Center/Lifecycle Management | Provides Rich Ecosystem Components and Scaffolding Tool

License

Notifications You must be signed in to change notification settings

gone-io/gone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EnglishΒ  |  δΈ­ζ–‡

license GoDoc Go Report Card codecov Build and Test Release Mentioned in Awesome Go

logo

πŸš€ 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):

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
  • 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

architecture

Lifecycle

flow

🏁 Quick Start

Environment Preparation

  1. Install required tools
go install github.com/gone-io/gonectl@latest
go install go.uber.org/mock/mockgen@latest

Create Project

gonectl create myproject
cd myproject

Run Project

go mod tidy
gonectl run ./cmd/server

More Documents

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 or submit a pull request.

Contact

If you have any questions, welcome to contact us through:

License

gone is released under the MIT License, see LICENSE for details.

About

πŸš€ Gone - A Lightweight Dependency Injection Framework for Go | Tag-based Auto Injection | Supports Config Center/Lifecycle Management | Provides Rich Ecosystem Components and Scaffolding Tool

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages