/
gproc_must.go
35 lines (30 loc) · 970 Bytes
/
gproc_must.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/wowqhb/gf.
package gproc
import (
"context"
"io"
)
// MustShell performs as Shell, but it panics if any error occurs.
func MustShell(ctx context.Context, cmd string, out io.Writer, in io.Reader) {
if err := Shell(ctx, cmd, out, in); err != nil {
panic(err)
}
}
// MustShellRun performs as ShellRun, but it panics if any error occurs.
func MustShellRun(ctx context.Context, cmd string) {
if err := ShellRun(ctx, cmd); err != nil {
panic(err)
}
}
// MustShellExec performs as ShellExec, but it panics if any error occurs.
func MustShellExec(ctx context.Context, cmd string, environment ...[]string) string {
result, err := ShellExec(ctx, cmd, environment...)
if err != nil {
panic(err)
}
return result
}