utils.go 404 B

123456789101112131415161718192021
  1. package utils
  2. import (
  3. "strings"
  4. )
  5. // ParseTagOption parse tag options to hash
  6. func ParseTagOption(str string) map[string]string {
  7. tags := strings.Split(str, ";")
  8. setting := map[string]string{}
  9. for _, value := range tags {
  10. v := strings.Split(value, ":")
  11. k := strings.TrimSpace(strings.ToUpper(v[0]))
  12. if len(v) == 2 {
  13. setting[k] = v[1]
  14. } else {
  15. setting[k] = k
  16. }
  17. }
  18. return setting
  19. }