ITADN

Need a method to avoid the panic when os.Stdout is nil on windows platform.

#250Openchenjie4255 创建于 2025-02-08
C
chenjie4255commented
When the program is running as Windows system services, the os.stdout is nil. which results in a panic. ``` panic: nil passed instead of *os.File to NewColorable() goroutine 1 [running]: github.com/mattn/go-colorable.NewColorable(0x0) C:/Users/chen/go/pkg/mod/github.com/mattn/go-colorable@v0.1.13/colorable_windows.go:104 +0x3d6 github.com/mattn/go-colorable.NewColorableStdout() C:/Users/chen/go/pkg/mod/github.com/mattn/go-colorable@v0.1.13/colorable_windows.go:122 +0x25 github.com/fatih/color.init() C:/Users/chen/go/pkg/mod/github.com/fatih/color@v1.13.0/color.go:27 +0x12d ``` link issue: https://github.com/mattn/go-colorable/issues/76 Maybe we need a method to avoid calling the ```go-colorable.NewColorableStdout()``` when the os.Stdout is nil?
0 条评论