Fix parsing for property values containing '='#18
Fix parsing for property values containing '='#18jk53bg wants to merge 1 commit intohooklift:masterfrom
Conversation
|
Hey @johlandabee, thanks for sending this over! |
| extendedconfigfile = "generic-ubuntu1804-vmware.vmxf" | ||
| floppy0.present = "FALSE" | ||
| guestos = "ubuntu-64" | ||
| guestos.detailed.data = "bitness='64' distroName='Ubuntu' distroVersion='18.04' familyName='Linux' kernelVersion='4.15.0-76-generic' prettyName='Ubuntu 18.04.4 LTS'" |
There was a problem hiding this comment.
It seems a splitN would do it, no need for the regular expression unless I'm missing something here.
There was a problem hiding this comment.
here is an example: https://play.golang.org/p/tCDvzaz_Hjg
There was a problem hiding this comment.
Yeah, that should do it. Didn't think of SplitN. Nice thing about the regular expression is you don't need to check for comments, empty values or unquote separately. That is assuming there are never values without quotes.
There was a problem hiding this comment.
They are also harder to maintain, more inefficient and often come with unexpected side effects.
There was a problem hiding this comment.
Well it might not be as efficient, but less code also leaves less margin for error. I don't necessarily agree on the maintainability or side effect aspect, but I can change the PR if you want.
There was a problem hiding this comment.
Well it might not be as efficient, but less code also leaves less margin for error
Agreed, it is another reason why I prefer using strings.SplitN(), it solves the problem with the least amount of code involved.
Parse key value pairs using named regex groups. This should be overall more error tolerant.
Regex explained at https://regex101.com/r/8ImGSW/1
Fixes #17