string_windows.go 868 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //go:build windows
  2. // +build windows
  3. package color
  4. import (
  5. "fmt"
  6. "math/rand"
  7. "strconv"
  8. )
  9. var _ = RandomColor()
  10. // RandomColor generates a random color.
  11. func RandomColor() string {
  12. return fmt.Sprintf("#%s", strconv.FormatInt(int64(rand.Intn(16777216)), 16))
  13. }
  14. // Yellow ...
  15. func Yellow(msg string) string {
  16. return fmt.Sprintf("\033[33m%s\033[0m", msg)
  17. }
  18. // Red ...
  19. func Red(msg string) string {
  20. return fmt.Sprintf("\033[31m%s\033[0m", msg)
  21. }
  22. // Redf ...
  23. func Redf(msg string, arg any) string {
  24. return fmt.Sprintf("\033[31m%s\033[0m %+v\n", msg, arg)
  25. }
  26. // Blue ...
  27. func Blue(msg string) string {
  28. return fmt.Sprintf("\033[34m%s\033[0m", msg)
  29. }
  30. // Green ...
  31. func Green(msg string) string {
  32. return fmt.Sprintf("\033[32m%s\033[0m", msg)
  33. }
  34. // Greenf ...
  35. func Greenf(msg string, arg any) string {
  36. return fmt.Sprintf("\033[32m%s\033[0m %+v\n", msg, arg)
  37. }