From 58f28fb1bb19311dd1b04f273f44fecc504fbf34 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Thu, 11 Dec 2014 17:32:09 +0000 Subject: [PATCH] more doc info --- main.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 4267533..de4f500 100644 --- a/main.go +++ b/main.go @@ -77,9 +77,18 @@ func writelines(f *fileOpener, c chan []byte) { // path. type fileOpener struct { *os.File + + // name of the file to be opened fname string - flag int - mode os.FileMode + + // file create flags to be passed to os.Open when opening the file.. If + // you don't include os.O_APPEND you're most likely doing it wrong. + flag int + + // file permissions on file to be created, passed to os.Open. If you don't + // include os.O_CREATE in the flags then this is inconsequential since + // we're not going to create new files anyway. + mode os.FileMode } func (f *fileOpener) Open() error { @@ -94,7 +103,10 @@ func (f *fileOpener) Open() error { // closes and reopens the file found at the fileopener's specified path. If // the original file has moved, reopen will cause the fileopener to change which // inode it points to. If the original file has been moved or deleted, and a -// new file has not been created in its place, +// new file has not been created in its place, the fileOpener *may* create a +// new file, depending on its initial flags. (spoiler alert: since we only use +// this once, and we do include the create flag, reopen will always create a +// file if none exists) func (f *fileOpener) Reopen() error { if err := f.Close(); err != nil { return fmt.Errorf("fileOpener unable to reopen file: %v", err)