package vinegarUtil import ( "bytes" gzip2 "compress/gzip" "io/ioutil" "os" ) func GetDiskContent(filePath string) (*[]byte, bool) { _, ferr := os.Stat(filePath) if os.IsNotExist(ferr) { return nil, false } else { f, err := os.OpenFile(filePath, os.O_RDONLY, 0755) if err != nil { panic(err) } defer f.Close() content, err := ioutil.ReadAll(f) if err != nil { panic(err) } return &content, true } } func GZipBytes(uncompressed *[]byte) *[]byte { buff := bytes.Buffer{} gzip := gzip2.NewWriter(&buff) _, err := gzip.Write(*uncompressed) if err != nil { panic(err) } err = gzip.Flush() if err != nil { panic(err) } compressed := buff.Bytes() return &compressed }