https://github.com/caiyunapp/oap
Read Apollo tag and write to struct field
https://github.com/caiyunapp/oap
apollo-config apollo-configuration
Last synced: 3 months ago
JSON representation
Read Apollo tag and write to struct field
- Host: GitHub
- URL: https://github.com/caiyunapp/oap
- Owner: caiyunapp
- License: mit
- Created: 2022-04-11T15:34:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-15T13:13:55.000Z (7 months ago)
- Last Synced: 2025-03-07T03:33:17.847Z (3 months ago)
- Topics: apollo-config, apollo-configuration
- Language: Go
- Homepage: https://pkg.go.dev/github.com/caiyunapp/oap
- Size: 61.5 KB
- Stars: 0
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Decode Apollo config to strcut field
Install via:
```bash
go install github.com/caiyunapp/oap
```Usage like:
```go
import "github.com/caiyunapp/oap"type DemoConfig struct {
Int int `apollo:"int"`
Int8 int8 `apollo:"int8"`
Int16 int16 `apollo:"int16"`
Int32 int32 `apollo:"int32"`
Int64 int64 `apollo:"int64"`
Uint uint `apollo:"uint"`
Uint8 uint8 `apollo:"uint8"`
Uint16 uint16 `apollo:"uint16"`
Uint32 uint32 `apollo:"uint32"`
Uint64 uint64 `apollo:"uint64"`
Duration time.Duration `apollo:"duration"`
}func main(){
// init your apollo client here
// ...conf := &DemoConfig{}
if err := oap.Decode(conf, client, make(map[string][]agollo.OpOption)); err != nil {
panic(err)
}
}
```Support types:
- [x] String
- [x] Int
- [x] Bool
- [x] Float32
- [x] Float64
- [x] Struct from JSON or YAML