From 83e37e3326921806642351c59761b16919c10e72 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 18 Sep 2016 15:09:53 +0200 Subject: Add EncodeFile --- file.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'file.go') diff --git a/file.go b/file.go index e321695..eaee236 100644 --- a/file.go +++ b/file.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "errors" + "fmt" "io/ioutil" "os" "strings" @@ -57,3 +58,17 @@ func ParseFile(fname string) (File, error) { Body: body, }, nil } + +func (f File) EncodeFile(fname string) error { + fd, err := os.Create(fname) + if err != nil { + return err + } + defer fd.Close() + fmt.Fprintln(fd, commentHdr, f.Comment) + fmt.Fprintln(fd, string(f.B64)) + if f.Body != nil { + fmt.Fprintln(fd, string(f.Body)) + } + return nil +} -- cgit v1.2.3