Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/u2takey/go-annotation
Annotation libraries and tools for golang.
https://github.com/u2takey/go-annotation
Last synced: 16 days ago
JSON representation
Annotation libraries and tools for golang.
- Host: GitHub
- URL: https://github.com/u2takey/go-annotation
- Owner: u2takey
- License: apache-2.0
- Created: 2020-05-21T08:38:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-30T16:07:05.000Z (over 4 years ago)
- Last Synced: 2024-10-03T12:33:33.999Z (about 1 month ago)
- Language: Go
- Size: 23.4 KB
- Stars: 40
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go-annotation
Annotation libraries and tools for golang.# Docs
Annotation 旨在设计一个适用于 golang 的 annotation 系统,实现类似 Java 的 Annotation 系统,以及常见插件,并提供一定的灵活性用于支持外部插件。使用 `Annotation@Annotation` 名字 表示使用一个具体的 annotation, 目前内置两个插件 `Description` 和 `Component`
例如, 用 Annotation 系统实现的内置插件 `Component`, 实现了类似 Java 中的依赖注入功能, 具体使用请参考 examples/example_test.go
```golang
// Annotation@Component
type ComponentA struct {
B1 *ComponentB `autowired:"true"` // Will populate with new(ComponentB)
B2 *ComponentB `autowired:"true"` // Will populate with new(ComponentB)
B3 *ComponentB
}// Annotation@Component={"type": "Singleton"}
type ComponentB struct {
C *ComponentC `autowired:"true"` // Will populate with NewComponentC()
}// Annotation@Component
type ComponentC struct {
D *ComponentD `autowired:"true"` // Will populate with NewComponentD()
IntValue int
}func NewComponentC() *ComponentC {
return &ComponentC{IntValue: 1}
}// Annotation@Component
type ComponentD struct {
IntValue int
}func NewComponentD() (*ComponentD, error) {
return &ComponentD{IntValue: 2}, nil
}```
# RoadMap
[design](/docs/design.md)