source.go 397 B

123456789101112131415161718192021222324252627282930
  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. )
  14. var formatMap = map[Format]string{
  15. Yaml: "yaml",
  16. }
  17. func (f Format) String() string {
  18. return string(f)
  19. }
  20. func (f Format) Validate() bool {
  21. _, ok := formatMap[f]
  22. return ok
  23. }