We had a bug where a line [manifest_version]
was being added by accident.
Last active
May 30, 2025 08:35
-
-
Save Integralist/c29ff647e5fb2f5c5001aa50a9288d8f to your computer and use it in GitHub Desktop.
Go: remove line from file #go
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
authors = ["[email protected]"] | |
description = "testing" | |
language = "rust" | |
[manifest_version] | |
name = "testing" | |
service_id = "123" |
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 ( | |
"bufio" | |
"bytes" | |
"log" | |
"os" | |
) | |
func main() { | |
fpath := "fastly.toml" | |
f, err := os.Open(fpath) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer f.Close() | |
var bs []byte | |
buf := bytes.NewBuffer(bs) | |
scanner := bufio.NewScanner(f) | |
for scanner.Scan() { | |
if scanner.Text() != "[manifest_version]" { | |
_, err := buf.Write(scanner.Bytes()) | |
if err != nil { | |
log.Fatal(err) | |
} | |
_, err = buf.WriteString("\n") | |
if err != nil { | |
log.Fatal(err) | |
} | |
} | |
} | |
if err := scanner.Err(); err != nil { | |
log.Fatal(err) | |
} | |
err = os.WriteFile(fpath, buf.Bytes(), 0666) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment