Skip to content

Instantly share code, notes, and snippets.

@lidedongsn
Last active June 28, 2018 02:26
Show Gist options
  • Save lidedongsn/dea4020d22612ea2c4793b1bc80d55c0 to your computer and use it in GitHub Desktop.
Save lidedongsn/dea4020d22612ea2c4793b1bc80d55c0 to your computer and use it in GitHub Desktop.
sdp in one line "\n" or "\r\n" formated
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"strings"
)
var copyright string = "******** Create by LIDE ********"
var useage string = "Useage: sdp_parser -f <filename>"
func main() {
filename := flag.String("f", "sdp file", "sdp file given")
flag.Parse()
if count := len(os.Args); count != 3 {
fmt.Printf("%s\n", useage)
os.Exit(-1)
}
sdp, e := ioutil.ReadFile(*filename)
if e != nil {
fmt.Println("read file error", e.Error())
return
}
var sdp2 string = string(sdp)
fmt.Println("================================================================\n")
fmt.Println(copyright)
str := strings.Split(sdp2, "\\n")
for _, l := range str {
fmt.Println(strings.Replace(l, "\\r", "", -1))
}
fmt.Println("================================================================\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment