Created
October 2, 2014 01:14
-
-
Save dallarosa/b58b0e3425761e0a7cf6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io/ioutil" | |
"log" | |
"strings" | |
) | |
func main() { | |
input, err := ioutil.ReadFile("myfile") | |
if err != nil { | |
log.Fatalln(err) | |
} | |
lines := strings.Split(string(input), "\n") | |
for i, line := range lines { | |
if strings.Contains(line, "]") { | |
lines[i] = "LOL" | |
} | |
} | |
output := strings.Join(lines, "\n") | |
err = ioutil.WriteFile("myfile", []byte(output), 0644) | |
if err != nil { | |
log.Fatalln(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey,
ioutil
is deprecated now, but we can use theos
package instead.