Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(go-runtime): use fatih/color instead of ANSI Escape Code #4109

Merged
merged 4 commits into from
Jul 3, 2023

Conversation

wafuwafu13
Copy link
Contributor

ANSI Escape Codes don't work in Windows so use fatih/color .

Debug code(ANSI):

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

Result(Windows_Server-2022):
スクリーンショット 2023-05-21 18 08 08

Debug code(fatih/color):

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

Result(Windows_Server-2022):
スクリーンショット 2023-05-21 18 24 13


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

RomainMuller
RomainMuller previously approved these changes Jun 15, 2023
@RomainMuller
Copy link
Contributor

Hey!

Sorry I only see this now... thanks for this!

@mergify mergify bot dismissed RomainMuller’s stale review July 3, 2023 12:38

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jul 3, 2023

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Jul 3, 2023
@mergify
Copy link
Contributor

mergify bot commented Jul 3, 2023

Merging (with squash)...

@mergify
Copy link
Contributor

mergify bot commented Jul 3, 2023

Merging (with squash)...

@mergify mergify bot merged commit 28b192a into aws:main Jul 3, 2023
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants