Commit 28b192a
authored
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):

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):

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.01 parent 6b7eb02 commit 28b192a
File tree
3 files changed
+11
-2
lines changed- packages/@jsii/go-runtime/jsii-runtime-go
3 files changed
+11
-2
lines changedLines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
| |||
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
0 commit comments