Home >Backend Development >Golang >Why Does My Go `exec.Command('mv', '*')` Fail with 'exit status 1'?
Go: Error "Failed to Execute Command" When Using Wildcard Character
When attempting to execute an "mv" command using Go's exec package, an error message stating "exit status 1" may occur. This issue arises when using wildcards, such as "*", in the command.
The problem lies in the way the shell interprets the command. When a wildcard is entered at the shell, it is expanded into a list of matching filenames. However, when using the exec package, the wildcard is not expanded, and the command is executed with the wildcard itself as an argument.
To resolve this issue, two approaches can be taken:
The above is the detailed content of Why Does My Go `exec.Command('mv', '*')` Fail with 'exit status 1'?. For more information, please follow other related articles on the PHP Chinese website!