source.go 434 B

1234567891011121314151617181920212223242526272829303132
  1. package config
  2. import (
  3. "github.com/go-kratos/kratos/v2/config"
  4. )
  5. type Source interface {
  6. NewSource() (config.Source, error)
  7. Validate() bool
  8. String() string
  9. }
  10. type Format string
  11. const (
  12. Yaml Format = "yaml"
  13. Json Format = "json"
  14. )
  15. var formatMap = map[Format]string{
  16. Yaml: "yaml",
  17. Json: "json",
  18. }
  19. func (f Format) String() string {
  20. return string(f)
  21. }
  22. func (f Format) Validate() bool {
  23. _, ok := formatMap[f]
  24. return ok
  25. }