refactor(envexec): minor modification

This commit is contained in:
criyle 2025-05-25 21:01:18 -04:00
parent 8c03485866
commit cf2e097a6b
4 changed files with 5 additions and 5 deletions

View File

@ -97,7 +97,7 @@ func (s Status) MarshalJSON() ([]byte, error) {
// UnmarshalJSON convert string into status
func (s *Status) UnmarshalJSON(b []byte) error {
str := string(b)
v, err := envexec.StringToStatus(str)
v, err := envexec.StringToStatus(str[1 : len(str)-1])
if err != nil {
return err
}

View File

@ -144,7 +144,7 @@ func (t FileErrorType) MarshalJSON() ([]byte, error) {
func (t *FileErrorType) UnmarshalJSON(b []byte) error {
str := string(b)
v, ok := fileErrorStringReverse[str]
if ok {
if !ok {
return fmt.Errorf("%s is not file error type", str)
}
*t = v

View File

@ -68,7 +68,7 @@ func prepareCmdFdTTY(c *Cmd, count int, newStoreFile NewStoreFile) (f []*os.File
var f *os.File
f, err = os.Open(t.Path)
if err != nil {
return nil, nil, fmt.Errorf("failed to open file %v", t.Path)
return nil, nil, fmt.Errorf("failed to open file: %v", t.Path)
}
files[j] = f
@ -163,7 +163,7 @@ func prepareCmdFd(c *Cmd, count int, newFileStore NewStoreFile) (f []*os.File, p
case *FileInput:
f, err := os.Open(t.Path)
if err != nil {
return nil, nil, fmt.Errorf("failed to open file %v", t.Path)
return nil, nil, fmt.Errorf("failed to open file: %v", t.Path)
}
files[j] = f

View File

@ -77,6 +77,6 @@ func StringToStatus(s string) (Status, error) {
func init() {
for i, v := range statusToString {
stringToStatus["\""+v+"\""] = Status(i)
stringToStatus[v] = Status(i)
}
}