This question already has an answer here:
I am running a Go program that generates a file in gif format. When using Bash or Command Prompt, the file is generated successfully. However, when using PowerShell or PowerShell-Core, I receive an error: "The image ‘file:///C:\Users\blah\blah\blah’ cannot be displayed because it contains errors".
How can I generate this file correctly using PowerShell?
I have attempted to run the exact same commands that worked on Bash and Command Prompt. I have also tried using PowerShell cmdlets like Out-File and Tee-Object.
go build main.go .\main.exe > out.gif firefox out.gif
Performing the above actions in Bash or Command Prompt generate the file and the expected gif. Performing the action in PowerShell yields the error message described above (image cannot be displayed because it contains errors).
I have also tried:
.\main.exe | Out-File out.gif and .\main.exe | Tee-Object out.gif
Both generate the broken file.