How to append to file before specific string in go?
I have a file that starts with this structure:
locals {
MY_LIST = [
"a",
"b",
"c",
"d"
//add more text before this
]
}
I want to add in the text "e" before the "//add more text before this" and "," after the "d" so it will be like this:
locals {
MY_LIST = [
"a",
"b",
"c",
"d",
"e"
//add more text before this
]
}
How can I implement this dynamically so that I can add more strings to the file in the future?
Thanks
Comments
Post a Comment