附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 месеца
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package flags
  2. import "errors"
  3. const (
  4. // CacheAlterTable is 修改表缓存名
  5. CacheAlterTable string = "db_center_alter_table"
  6. // CacheUserMigrate is 用户迁移
  7. CacheUserMigrate string = "user_migrate"
  8. )
  9. // BoolFlag is type of map[string]bool
  10. type BoolFlag map[string]bool
  11. // BoolFlagMap is mapping bool
  12. var BoolFlagMap = BoolFlag{
  13. "1": true,
  14. "true": true,
  15. "True": true,
  16. "0": false,
  17. "false": false,
  18. "False": false,
  19. }
  20. // BoundCheck is return false and err if is not found
  21. func (b BoolFlag) BoundCheck(flag string) (bool, error) {
  22. bl, ok := b[flag]
  23. if !ok {
  24. return false, errors.New("Flag Not Mapping Any Key")
  25. }
  26. return bl, nil
  27. }
  28. // Check is not found return flase
  29. func (b BoolFlag) Check(flag string) bool {
  30. bl, ok := b[flag]
  31. if !ok {
  32. return false
  33. }
  34. return bl
  35. }