setfieldsep.go raw

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