setfieldsep.go 727 B

1234567891011121314151617181920
  1. package mxj
  2. // Per: https://github.com/clbanning/mxj/issues/37#issuecomment-278651862
  3. var fieldSep string = ":"
  4. // SetFieldSeparator changes the default field separator, ":", for the
  5. // newVal argument in mv.UpdateValuesForPath and the optional 'subkey' arguments
  6. // in mv.ValuesForKey and mv.ValuesForPath.
  7. //
  8. // E.g., if the newVal value is "http://blah/blah", setting the field separator
  9. // to "|" will allow the newVal specification, "<key>|http://blah/blah" to parse
  10. // properly. If called with no argument or an empty string value, the field
  11. // separator is set to the default, ":".
  12. func SetFieldSeparator(s ...string) {
  13. if len(s) == 0 || s[0] == "" {
  14. fieldSep = ":" // the default
  15. return
  16. }
  17. fieldSep = s[0]
  18. }