Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.
/ go-spring Public archive
forked from go-spring/go-spring

Go-Spring vision is to empower Go programmers with a powerful programming framework

License

Notifications You must be signed in to change notification settings

limpo1989/go-spring

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Spring

GoDoc license-Apache 2

Go-Spring vision is to empower Go programmers with a powerful programming framework similar to Java Spring. It is dedicated to providing users with a simple, secure, and reliable programming experience.

This project based from go-spring/go-spring created by lvan100

  • Switch to monolithic repository.
  • Remove third-party modules and retain only the core dependency injection functionality.
  • Invoke AppRunner and AppEvent in the order of their dependencies.
  • Add the dynamic property types like Array/Map/Value.
  • Add named logger.

IoC container

In addition to implementing a powerful IoC container similar to Java Spring, Go-Spring also extends the concept of beans. In Go, objects (pointers), arrays, maps, and function pointers can all be considered beans and can be placed in the IoC container.

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

Property binding

Go-Spring not only supports property binding for primitive data types but also supports property binding for custom value types. It also provides support for nested binding of struct properties.

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}"`
}

The above code can be bound using the following configuration:

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

License

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

About

Go-Spring vision is to empower Go programmers with a powerful programming framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%