1 package writer 2 3 import ( 4 "io" 5 "time" 6 ) 7 8 // GzipWriter implements the functions needed for compressing content. 9 type GzipWriter interface { 10 Write(p []byte) (int, error) 11 Close() error 12 Flush() error 13 } 14 15 // GzipWriterExt implements the functions needed for compressing content 16 // and optional extensions. 17 type GzipWriterExt interface { 18 GzipWriter 19 20 // SetHeader will populate header fields with non-nil values in h. 21 SetHeader(h Header) 22 } 23 24 // Header is a gzip header. 25 type Header struct { 26 Comment string // comment 27 Extra []byte // "extra data" 28 ModTime time.Time // modification time 29 Name string // file name 30 OS byte // operating system type 31 } 32 33 // GzipWriterFactory contains the information needed for custom gzip implementations. 34 type GzipWriterFactory struct { 35 // Must return the minimum and maximum supported level. 36 Levels func() (min, max int) 37 38 // New must return a new GzipWriter. 39 // level will always be within the return limits above. 40 New func(writer io.Writer, level int) GzipWriter 41 } 42