Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(go-runtime): use fatih/color instead of ANSI Escape Code (#4109)
ANSI Escape Codes don't work in Windows so use [fatih/color](https://github.com/fatih/color) . Debug code(ANSI): ```go package main import ( "fmt" "os" ) func main() { fmt.Fprintf(os.Stderr, "\u001b[31m\u001b[1m") fmt.Fprintln(os.Stderr, "###########################################################") fmt.Fprintf(os.Stderr, "\u001b[0m") fmt.Fprintln(os.Stderr, "###########################################################") } ``` Result(Amazon Linux 2023): ![スクリーンショット 2023-05-21 18 08 16](https://github.com/aws/jsii/assets/50798936/2318d7a3-8cb5-4cd6-8275-682b9b307563) Result(Windows_Server-2022): <img width="554" alt="スクリーンショット 2023-05-21 18 08 08" src="https://github.com/aws/jsii/assets/50798936/9d1615ac-825e-4039-b9c6-d65a69298d89"> Debug code(fatih/color): ```go package main import ( "fmt" "os" "github.com/fatih/color" "github.com/mattn/go-isatty" ) func main() { fmt.Printf("res: %v\n", isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) color.Set(color.FgRed) fmt.Fprintln(os.Stderr, "###########################################################") color.Unset() fmt.Fprintln(os.Stderr, "###########################################################") } ``` Result(Amazon Linux 2023): ![スクリーンショット 2023-05-21 18 24 38](https://github.com/aws/jsii/assets/50798936/4c6b76b0-5ce5-48f7-810d-a640de8e0167) Result(Windows_Server-2022): <img width="484" alt="スクリーンショット 2023-05-21 18 24 13" src="https://github.com/aws/jsii/assets/50798936/182984c5-eedd-447e-88d7-33c46939ace8"> --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
- Loading branch information