Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
1.2 KiB
Go
70 lines
1.2 KiB
Go
package datautils
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
"compress/zlib"
|
|
"fmt"
|
|
"io/ioutil"
|
|
)
|
|
|
|
const (
|
|
None = iota
|
|
GZip
|
|
Zlib
|
|
)
|
|
|
|
func Compress(data []byte, compressType int) ([]byte, error) {
|
|
var b bytes.Buffer
|
|
switch compressType {
|
|
case GZip:
|
|
gz := gzip.NewWriter(&b)
|
|
if _, err := gz.Write(data); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := gz.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
return b.Bytes(), nil
|
|
case Zlib:
|
|
zl := zlib.NewWriter(&b)
|
|
if _, err := zl.Write(data); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := zl.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
return b.Bytes(), nil
|
|
}
|
|
return nil, fmt.Errorf("compression type not found")
|
|
}
|
|
|
|
func Decompress(data []byte, compressType int) ([]byte, error) {
|
|
b := bytes.NewReader(data)
|
|
switch compressType {
|
|
case GZip:
|
|
gz, err := gzip.NewReader(b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer gz.Close()
|
|
raw, err := ioutil.ReadAll(gz)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return raw, nil
|
|
case Zlib:
|
|
zl, err := zlib.NewReader(b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer zl.Close()
|
|
raw, err := ioutil.ReadAll(zl)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return raw, nil
|
|
}
|
|
return nil, fmt.Errorf("compression type not found")
|
|
}
|