All Projects → go-spring → Go Spring

go-spring / Go Spring

Licence: apache-2.0
基于 IoC 的 Go 后端一站式开发框架 🚀

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Go Spring

Typedi
Simple yet powerful dependency injection tool for JavaScript and TypeScript.
Stars: ✭ 2,832 (+280.65%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
iocgo
A lightweight Inversion of Control (IoC) (Dependency Injection) container for Golang
Stars: ✭ 36 (-95.16%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
Typhoon
Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Stars: ✭ 2,711 (+264.38%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
React Ioc
Hierarchical Dependency Injection with new React 16 Context API
Stars: ✭ 133 (-82.12%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
diod
A very opinionated inversion of control (IoC) container and dependency injector for Typescript, Node.js or browser apps.
Stars: ✭ 36 (-95.16%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
Qframework
Unity3D System Design Architecture
Stars: ✭ 2,326 (+212.63%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
waiter
Dependency injection, Inversion of control container for rust with compile time binding.
Stars: ✭ 71 (-90.46%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
stashbox
A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
Stars: ✭ 120 (-83.87%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
ThunderboltIoc
One of the very first IoC frameworks for .Net that has no reflection. An IoC that casts its services before thunder casts its bolts.
Stars: ✭ 40 (-94.62%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
vue-ioc
IoC and DI for Vue powered by InversifyJS and inspired by Angular Module syntactic sugar.
Stars: ✭ 39 (-94.76%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
Container Ioc
Inversion of Control container & Dependency Injection for Javascript and Node.js apps powered by Typescript.
Stars: ✭ 89 (-88.04%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Kangaru
🦘 A dependency injection container for C++11, C++14 and later
Stars: ✭ 297 (-60.08%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (-91.53%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Ioc
🦄 lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript
Stars: ✭ 171 (-77.02%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
vesselize
⛵ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-97.04%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
granitic
Web/micro-services and IoC framework for Golang developers
Stars: ✭ 32 (-95.7%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
Ditranquillity
Dependency injection for iOS (Swift)
Stars: ✭ 317 (-57.39%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Dryioc
DryIoc is fast, small, full-featured IoC Container for .NET
Stars: ✭ 555 (-25.4%)
Mutual labels:  dependency-injection, inversion-of-control
Spring Boot Klock Starter
基于redis的分布式锁组件,简单方便快捷接入项目,使项目拥有分布式锁能力
Stars: ✭ 546 (-26.61%)
Mutual labels:  spring-boot, spring
Books Recommendation
程序员进阶书籍(视频),持续更新(Programmer Books)
Stars: ✭ 558 (-25%)
Mutual labels:  spring-boot, spring
logo
license go-version release

Go-Spring 的愿景是让 Go 程序员也能用上如 Java Spring 那般威力强大的编程框架。

其特性如下:

  1. 提供了完善的 IoC 容器,支持依赖注入、属性绑定;
  2. 提供了强大的启动器框架,支持自动装配、开箱即用;
  3. 提供了常见组件的抽象层,支持灵活地替换底层实现;

Go-Spring 当前使用 Go1.12 进行开发,使用 Go Modules 进行依赖管理。

IoC 容器

Go-Spring 不仅实现了如 Java Spring 那般功能强大的 IoC 容器,还扩充了 Bean 的概念。在 Go 中,对象(即指针)、数组、Map、函数指针,这些都是 Bean,都可以放到 IoC 容器里。

常用的 Java Spring 注解 对应的 Go-Spring 实现
@Value value:"${}"
@Autowired @Qualifier @Required autowire:"?"
@Configurable WireBean()
@Profile ConditionOnProfile()
@Primary Primary()
@DependsOn DependsOn()
@ConstructorBinding RegisterBeanFn()
@ComponentScan @Indexed Package Import
@Conditional NewConditional()
@ConditionalOnExpression NewExpressionCondition()
@ConditionalOnProperty NewPropertyValueCondition()
@ConditionalOnBean NewBeanCondition()
@ConditionalOnMissingBean NewMissingBeanCondition()
@ConditionalOnClass Don't Need
@ConditionalOnMissingClass Don't Need
@Lookup ——

属性绑定

Go-Spring 不仅支持对普通数据类型进行属性绑定,也支持对自定义值类型进行属性绑定,而且还支持对结构体属性的嵌套绑定。

type DB struct {
	UserName string `value:"${username}"`
	Password string `value:"${password}"`
	Url      string `value:"${url}"`
	Port     string `value:"${port}"`
	DB       string `value:"${db}"`
}

type DbConfig struct {
	DB []DB `value:"${db}"`
}

上面这段代码可以通过下面的配置进行绑定:

db:
  -
    username: root
    password: 123456
    url: 1.1.1.1
    port: 3306
    db: db1
  -
    username: root
    password: 123456
    url: 1.1.1.1
    port: 3306
    db: db2

Boot 框架

Go-Spring 提供了一个功能强大的启动器框架,不仅实现了自动加载、开箱即用,而且可以非常容易的开发自己的启动器模块,使得代码不仅仅是库层面的复用。

快速示例

下面的示例使用 v1.0.5 版本测试通过。

import (
	"context"

	"github.com/go-spring/spring-boot"
	_ "github.com/go-spring/starter-echo"
)

func init() {
	SpringBoot.RegisterBean(new(Service)).Init(func(s *Service) {
		SpringBoot.GetBinding("/", s.Echo)
	})
}

type Service struct {
	GoPath string `value:"${GOPATH}"`
}

type EchoRequest struct{}

func (s *Service) Echo(ctx context.Context, req *EchoRequest) interface{} {
	return s.GoPath
}

func main() {
	SpringBoot.RunApplication()
}

启动上面的程序,控制台输入 curl http://localhost:8080/, 可得到如下结果:

{"code":200,"msg":"SUCCESS","data":"/Users/didi/go"}

更多示例: https://github.com/go-spring/go-spring/tree/master/examples

详细文档

https://docs.lavend.net/

项目成员

发起者(负责人)

@lvan100 (LiangHuan)

优秀贡献者

@CoderPoet@limpo1989

特别鸣谢

@shenqidebaozi

如何成为贡献者?提交有意义的 PR 或者需求,并被采纳。

QQ 交流群


QQ群号:721077608

微信公众号

License

The Go-Spring is released under version 2.0 of the Apache License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].