Skip to content

Instantly share code, notes, and snippets.

@montanaflynn
Last active August 29, 2015 14:22
Show Gist options
  • Save montanaflynn/a13f9d5461409b6c39c4 to your computer and use it in GitHub Desktop.
Save montanaflynn/a13f9d5461409b6c39c4 to your computer and use it in GitHub Desktop.
Siege log formatter
package main
import (
"regexp"
"io/ioutil"
"os"
)
func replace(reg, repl, text string) string {
regex, _ := regexp.Compile(reg)
result := regex.ReplaceAllString(text, repl)
return result
}
func main() {
path := string(os.Args[1])
buf, err := ioutil.ReadFile(path)
if err != nil {
return
}
str := string(buf)
str = "Description, " + str[6:]
tmp := replace("\\*\\*\\*\\*.", "", str)
end := replace("\\s\\*\\*\\*\\*\n.", ", 2", tmp)
err = ioutil.WriteFile(path, []byte(end), 0644)
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment