func readFiles(filenames []string) ([]githubapi.File, error) { var files []githubapi.File for _, f := range filenames { c, e := ioutil.ReadFile(f) if e != nil { fmt.Println("Error reading file", e) os.Exit(1) } cleaned := githubapi.EscapeNLs(string(c)) files = append(files, githubapi.NewFile(f, cleaned)) } return files, nil }
func main() { dummy() // emacs.el does not format correctly without this help, desc, fname, args := setFlags() if help != false { printHelpMessage() os.Exit(0) } if len(args) == 0 { all := readStdin() gr := githubapi.PushGist(desc, githubapi.NewFile(fname, all)) fmt.Println(gr.Html_Url) } else { files, ferr := readFiles(args) if ferr != nil { fmt.Println("Error reading file", ferr) os.Exit(1) } gr := githubapi.PushMultiGist(desc, files) fmt.Println(gr.Html_Url) } }