(path string)
| 25 | ) |
| 26 | |
| 27 | func GetFileStream(path string) (io.Writer, errors.Error) { |
| 28 | if path == "" { |
| 29 | return os.Stdout, nil |
| 30 | } |
| 31 | err := os.MkdirAll(filepath.Dir(path), 0777) |
| 32 | if err != nil { |
| 33 | return nil, errors.Convert(err) |
| 34 | } |
| 35 | file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) |
| 36 | if err != nil { |
| 37 | return nil, errors.Convert(err) |
| 38 | } |
| 39 | return io.MultiWriter(os.Stdout, file), nil |
| 40 | } |