I have a text file that i'd like to add an a block of text to using Go. The text file looks like this (without the numbering)
- blah
- blah2
- ]
- blah3
- blah4
and i want it to look like this
- blah
- blah2
- MY INSERTED TEXT HERE
- ]
- blah3
- blah4
Assume I've already opened the file and created a string array of each line in the file called 'lines'.
//find line with ]
for i, line := range lines {
if(strings.ContainsRune(line, ']')) {
//take the line before ']'... and write to it somehow
lines[i-1] (?)
}
}
How do I do this?