Skip to content

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

Open
@chenjie4255

Description

@chenjie4255

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: mattn/go-colorable#76

Maybe we need a method to avoid calling the go-colorable.NewColorableStdout() when the os.Stdout is nil?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions