Skip to content

Commit 9cca0a3

Browse files
committed
Spelling and grammar fixes
1 parent 184b603 commit 9cca0a3

3 files changed

Lines changed: 71 additions & 72 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ There might be a case where you want to explicitly disable/enable color output.
132132
The `color` package also disables color output if the [`NO_COLOR`](https://no-color.org) environment
133133
variable is set (regardless of its value).
134134

135-
`Color` has support to disable/enable colors programatically both globally and
135+
`Color` has support to disable/enable colors programmatically both globally and
136136
for single color definitions. For example suppose you have a CLI app and a
137137
`--no-color` bool flag. You can easily disable the color output with:
138138

color.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222
NoColor = noColorExists() || os.Getenv("TERM") == "dumb" ||
2323
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
2424

25-
// Output defines the standard output of the print functions. By default
25+
// Output defines the standard output of the print functions. By default,
2626
// os.Stdout is used.
2727
Output = colorable.NewColorableStdout()
2828

@@ -390,7 +390,7 @@ func (c *Color) DisableColor() {
390390
}
391391

392392
// EnableColor enables the color output. Use it in conjunction with
393-
// DisableColor(). Otherwise this method has no side effects.
393+
// DisableColor(). Otherwise, this method has no side effects.
394394
func (c *Color) EnableColor() {
395395
c.noColor = boolPtr(false)
396396
}

doc.go

Lines changed: 68 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,131 +5,130 @@ that suits you.
55
66
Use simple and default helper functions with predefined foreground colors:
77
8-
color.Cyan("Prints text in cyan.")
8+
color.Cyan("Prints text in cyan.")
99
10-
// a newline will be appended automatically
11-
color.Blue("Prints %s in blue.", "text")
10+
// a newline will be appended automatically
11+
color.Blue("Prints %s in blue.", "text")
1212
13-
// More default foreground colors..
14-
color.Red("We have red")
15-
color.Yellow("Yellow color too!")
16-
color.Magenta("And many others ..")
13+
// More default foreground colors..
14+
color.Red("We have red")
15+
color.Yellow("Yellow color too!")
16+
color.Magenta("And many others ..")
1717
18-
// Hi-intensity colors
19-
color.HiGreen("Bright green color.")
20-
color.HiBlack("Bright black means gray..")
21-
color.HiWhite("Shiny white color!")
18+
// Hi-intensity colors
19+
color.HiGreen("Bright green color.")
20+
color.HiBlack("Bright black means gray..")
21+
color.HiWhite("Shiny white color!")
2222
23-
However there are times where custom color mixes are required. Below are some
23+
However, there are times when custom color mixes are required. Below are some
2424
examples to create custom color objects and use the print functions of each
2525
separate color object.
2626
27-
// Create a new color object
28-
c := color.New(color.FgCyan).Add(color.Underline)
29-
c.Println("Prints cyan text with an underline.")
27+
// Create a new color object
28+
c := color.New(color.FgCyan).Add(color.Underline)
29+
c.Println("Prints cyan text with an underline.")
3030
31-
// Or just add them to New()
32-
d := color.New(color.FgCyan, color.Bold)
33-
d.Printf("This prints bold cyan %s\n", "too!.")
31+
// Or just add them to New()
32+
d := color.New(color.FgCyan, color.Bold)
33+
d.Printf("This prints bold cyan %s\n", "too!.")
3434
3535
36-
// Mix up foreground and background colors, create new mixes!
37-
red := color.New(color.FgRed)
36+
// Mix up foreground and background colors, create new mixes!
37+
red := color.New(color.FgRed)
3838
39-
boldRed := red.Add(color.Bold)
40-
boldRed.Println("This will print text in bold red.")
39+
boldRed := red.Add(color.Bold)
40+
boldRed.Println("This will print text in bold red.")
4141
42-
whiteBackground := red.Add(color.BgWhite)
43-
whiteBackground.Println("Red text with White background.")
42+
whiteBackground := red.Add(color.BgWhite)
43+
whiteBackground.Println("Red text with White background.")
4444
45-
// Use your own io.Writer output
46-
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
45+
// Use your own io.Writer output
46+
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
4747
48-
blue := color.New(color.FgBlue)
49-
blue.Fprint(myWriter, "This will print text in blue.")
48+
blue := color.New(color.FgBlue)
49+
blue.Fprint(myWriter, "This will print text in blue.")
5050
5151
You can create PrintXxx functions to simplify even more:
5252
53-
// Create a custom print function for convenient
54-
red := color.New(color.FgRed).PrintfFunc()
55-
red("warning")
56-
red("error: %s", err)
53+
// Create a custom print function for convenient
54+
red := color.New(color.FgRed).PrintfFunc()
55+
red("warning")
56+
red("error: %s", err)
5757
58-
// Mix up multiple attributes
59-
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
60-
notice("don't forget this...")
58+
// Mix up multiple attributes
59+
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
60+
notice("don't forget this...")
6161
6262
You can also FprintXxx functions to pass your own io.Writer:
6363
64-
blue := color.New(FgBlue).FprintfFunc()
65-
blue(myWriter, "important notice: %s", stars)
66-
67-
// Mix up with multiple attributes
68-
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
69-
success(myWriter, don't forget this...")
64+
blue := color.New(FgBlue).FprintfFunc()
65+
blue(myWriter, "important notice: %s", stars)
7066
67+
// Mix up with multiple attributes
68+
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
69+
success(myWriter, don't forget this...")
7170
7271
Or create SprintXxx functions to mix strings with other non-colorized strings:
7372
74-
yellow := New(FgYellow).SprintFunc()
75-
red := New(FgRed).SprintFunc()
73+
yellow := New(FgYellow).SprintFunc()
74+
red := New(FgRed).SprintFunc()
7675
77-
fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
76+
fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
7877
79-
info := New(FgWhite, BgGreen).SprintFunc()
80-
fmt.Printf("this %s rocks!\n", info("package"))
78+
info := New(FgWhite, BgGreen).SprintFunc()
79+
fmt.Printf("this %s rocks!\n", info("package"))
8180
8281
Windows support is enabled by default. All Print functions work as intended.
83-
However only for color.SprintXXX functions, user should use fmt.FprintXXX and
82+
However, only for color.SprintXXX functions, user should use fmt.FprintXXX and
8483
set the output to color.Output:
8584
86-
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
85+
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
8786
88-
info := New(FgWhite, BgGreen).SprintFunc()
89-
fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
87+
info := New(FgWhite, BgGreen).SprintFunc()
88+
fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
9089
9190
Using with existing code is possible. Just use the Set() method to set the
9291
standard output to the given parameters. That way a rewrite of an existing
9392
code is not required.
9493
95-
// Use handy standard colors.
96-
color.Set(color.FgYellow)
94+
// Use handy standard colors.
95+
color.Set(color.FgYellow)
9796
98-
fmt.Println("Existing text will be now in Yellow")
99-
fmt.Printf("This one %s\n", "too")
97+
fmt.Println("Existing text will be now in Yellow")
98+
fmt.Printf("This one %s\n", "too")
10099
101-
color.Unset() // don't forget to unset
100+
color.Unset() // don't forget to unset
102101
103-
// You can mix up parameters
104-
color.Set(color.FgMagenta, color.Bold)
105-
defer color.Unset() // use it in your function
102+
// You can mix up parameters
103+
color.Set(color.FgMagenta, color.Bold)
104+
defer color.Unset() // use it in your function
106105
107-
fmt.Println("All text will be now bold magenta.")
106+
fmt.Println("All text will be now bold magenta.")
108107
109108
There might be a case where you want to disable color output (for example to
110109
pipe the standard output of your app to somewhere else). `Color` has support to
111110
disable colors both globally and for single color definition. For example
112111
suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
113112
the color output with:
114113
115-
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
114+
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
116115
117-
if *flagNoColor {
118-
color.NoColor = true // disables colorized output
119-
}
116+
if *flagNoColor {
117+
color.NoColor = true // disables colorized output
118+
}
120119
121120
You can also disable the color by setting the NO_COLOR environment variable to any value.
122121
123122
It also has support for single color definitions (local). You can
124123
disable/enable color output on the fly:
125124
126-
c := color.New(color.FgCyan)
127-
c.Println("Prints cyan text")
125+
c := color.New(color.FgCyan)
126+
c.Println("Prints cyan text")
128127
129-
c.DisableColor()
130-
c.Println("This is printed without any color")
128+
c.DisableColor()
129+
c.Println("This is printed without any color")
131130
132-
c.EnableColor()
133-
c.Println("This prints again cyan...")
131+
c.EnableColor()
132+
c.Println("This prints again cyan...")
134133
*/
135134
package color

0 commit comments

Comments
 (0)