1234567891011121314151617181920212223242526272829 |
- package util
- import (
- "github.com/klauspost/compress/zstd"
- "os/exec"
- "strings"
- )
- func ExpandShellString(s string) (string, error) {
- if strings.Contains(s, "$") {
- // Start a shell to expand the environment variables
- cmd := exec.Command("sh", "-c", "echo "+s)
- out, err := cmd.Output()
- if err != nil {
- return "", err
- }
- s = strings.TrimSpace(string(out))
- }
- return s, nil
- }
- func DecompressZstdBuffer(input []byte) ([]byte, error) {
- decoder, err := zstd.NewReader(nil)
- if err != nil {
- return nil, err
- }
- defer decoder.Close()
- return decoder.DecodeAll(input, nil)
- }
|