You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by GeorgeDuckman March 7, 2024
Hello,
I am attempting to use yq as a library in my Golang application. I want to merge two yaml contents that are contained in two different string variables.
I am aware that the yq command can be used to merge two YAML files :
yq -n 'load("file1.yaml") * load("file2.yaml")'
To use yqlib, I am using the StringEvaluator which only takes one input. I am concatenating my two variables into one as follows:
---
a: Hello
---
a: Goodbye
And I want the result to be :
---
a: Goodbye
Is there a way to do this ? I would prefer not to create temporary files if possible :)
I've also tried merging by select but it returns nothing.
Here is my minimal code sample if you want to try yourself :
There actually isn't a great way to do that at the moment, the Evaluate function runs through the documents inside the string one by one as a stream. I've added a new "EvaluateAll" function to StringEvaluator that you can use in the next release.
I'm a bit confused by the docs implies this elegant yq m file1.yml file2.yml, and the readme that outlines yq -n 'load("file1.yaml") * load("file2.yaml")'
I'm a bit confused by the docs implies this elegant yq m file1.yml file2.yml, and the readme that outlines yq -n 'load("file1.yaml") * load("file2.yaml")'
Is the coolio yq m a future concept?
the default page for docs is set at v2, while the latest version is v4
Discussed in #1966
Originally posted by GeorgeDuckman March 7, 2024
Hello,
I am attempting to use yq as a library in my Golang application. I want to merge two yaml contents that are contained in two different string variables.
I am aware that the yq command can be used to merge two YAML files :
yq -n 'load("file1.yaml") * load("file2.yaml")'
To use yqlib, I am using the StringEvaluator which only takes one input. I am concatenating my two variables into one as follows:
And I want the result to be :
Is there a way to do this ? I would prefer not to create temporary files if possible :)
I've also tried merging by select but it returns nothing.
Here is my minimal code sample if you want to try yourself :
Thank you in advance !
The text was updated successfully, but these errors were encountered: