shad-go/vegz/encode.go

18 lines
257 B
Go
Raw Normal View History

2022-05-05 16:08:49 +00:00
//go:build !solution
package vegz
import (
"compress/gzip"
"io"
)
func Encode(data []byte, w io.Writer) error {
ww := gzip.NewWriter(w)
defer func() { _ = ww.Close() }()
if _, err := ww.Write(data); err != nil {
return err
}
return ww.Flush()
}