feat: release for v1.2.1
Some checks are pending
Test and coverage / build (1.21.x) (push) Waiting to run
Test and coverage / build (1.22.x) (push) Waiting to run
Test and coverage / build (1.23.x) (push) Waiting to run

This commit is contained in:
dapeng 2024-11-24 11:46:08 +08:00
parent 08b20cb833
commit 8f332a94a2
4 changed files with 18 additions and 2 deletions

View File

@ -231,6 +231,11 @@ In Gone, components are abstracted as Goners, whose properties can inject other
If you have a bug report or feature request, you can [open an issue](https://github.com/gone-io/gone/issues/new), and [pull requests](https://github.com/gone-io/gone/pulls) are also welcome.
## Changelog
### v1.2.1
- Introduced **gone.Provider**, a factory function for injecting external components (such as structs, struct pointers, functions, and interfaces) that are not **Goner** into Goners filed which tag by `gone`.
- Fixed an issue where `gone.NewProviderPriest` failed to create a Priest for **gone.Provider** instances that generate interface types.
- Added test cases for `goner/gorm` and completed other missing test cases; updated documentation accordingly.
### v1.2.0
- Introduced a new `gone.GonerOption`, enabling type-based injection by delegating the task of constructing injected type instances to a **Goner** that implements `Suck(conf string, v reflect.Value, field reflect.StructField) error`.
- Added a helper function for implementing **Goner Provider**: `func NewProviderPriest[T any, P any](fn func(tagConf string, param P) (T, error)) Priest`.

View File

@ -224,6 +224,11 @@ curl -X POST 'http://localhost:8080/hello' \
## 📚[完整文档](https://goner.fun/zh/)
## 更新记录
### v1.2.1
- 定义 **gone.Provider**,一个工厂函数用于将 不是 **Goner** 的外部组件(结构体、结构体指针、函数、接口)注入到 属性需要注入的Goner
- 修复 `gone.NewProviderPriest` 无法为 生成接口类型的**gone.Provider**生成Priest;
- 为`goner/gorm`编写测试代码,补齐其他测试代码;文档更新。
### v1.2.0
- 提供一种新的 `gone.GonerOption`,可以将按类型注入,将构造注入类型实例的任务代理给一个实现了`Suck(conf string, v reflect.Value, field reflect.StructField) error`的**Goner**
- 提供了一个用于实现**Goner Provider**的辅助函数:`func NewProviderPriest[T any, P any](fn func(tagConf string, param P) (T, error)) Priest`

View File

@ -317,6 +317,12 @@ func (p *provider[T]) Suck(conf string, v reflect.Value, field reflect.StructFie
return nil
}
// Provider is a factory function template, which return `T` instance and goner framework will call this function to
// create a new `T` instance for Type `T` fields of a struct who need injected.
// The parameter `tagConf` is the tag string of the field, and the parameter `param` should be an anonymous struct which field can be tag by `gone` and injected by goner framework.
// The function should be used for NewProviderPriest to create a provider priest.
type Provider[P, T any] func(tagConf string, param P) (T, error)
// NewProviderPriest create a provider priest function for goner from a function like: `func(tagConf string, injectableStructParam struct{}) (provideType T, err error)`
// example:
// ```go
@ -334,7 +340,7 @@ func (p *provider[T]) Suck(conf string, v reflect.Value, field reflect.StructFie
//
// var priest = NewProviderPriest(NewMyGoner)
// ```
func NewProviderPriest[T any, P any](fn func(tagConf string, param P) (T, error)) Priest {
func NewProviderPriest[P, T any](fn Provider[P, T]) Priest {
p := provider[T]{}
t := new(T)

View File

@ -1,3 +1,3 @@
package gone
const Version = "v1.2.0"
const Version = "v1.2.1"