// ParseLiteralSource parses the source key=val pair into its component pieces.
// This functionality is distinguished from strings.SplitN(source, "=", 2) since
// it returns an error in the case of empty keys, values, or a missing equals sign.
ParseLiteralSource parses the source key=val pair into its component pieces.
This functionality is distinguished from strings.SplitN(source, "=", 2) since
it returns an error in the case of empty keys, values, or a missing equals sign.
// ParseLiteralSource parses the source key = val pair into its component pieces . // This functionality is distinguished from strings . SplitN ( source " = " 2 ) since // it returns an error in the case of empty keys values or a missing equals sign .
func parseLiteralSource(source string) (keyName, value string, err error) {
	if strings.Index(source, "=") == 0 {
		return "", "", fmt.Errorf("invalid literal source %v, expected key=value", source)
	}
	items := strings.SplitN(source, "=", 2)
	if len(items) != 2 {
		return "", "", fmt.Errorf("invalid literal source %v, expected key=value", source)
	}
	return items[0], strings.Trim(items[1], "\"'"), nil
}
func parseLiteralSource ( source string ) ( keyName , value string , err error ) { if strings . Index ( source , " " ) == 0 { return " " , " " , fmt . Errorf ( " " , source ) } items := strings . SplitN ( source , " " , 2 ) if len ( items ) != 2 { return " " , " " , fmt . Errorf ( " " , source ) } return items [ 0 ] , strings . Trim ( items [ 1 ] , " \" " ) , nil }
ParseLiteralSource parses the source key=val pair into its component pieces.
ParseLiteralSource parses the source key = val pair into its component pieces .
// leading equal is invalid // split after the first equal (so values can have the = character)