Skip to content

Commit adeaf74

Browse files
committed
remove the Output struct
1 parent cd819e0 commit adeaf74

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

cli/output.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,26 @@ import (
2020
)
2121

2222
var (
23-
defaultOutput = NewOutput()
24-
defaultWriter = os.Stdout
23+
defaultStdoutWriter = os.Stdout
2524
defaultStderrWriter = os.Stderr
2625
)
2726

2827
func DefaultWriter() io.Writer {
29-
return defaultWriter
28+
return defaultStdoutWriter
3029
}
3130

3231
func DefaultStderrWriter() io.Writer {
3332
return defaultStderrWriter
3433
}
3534

3635
func Print(w io.Writer, a ...interface{}) (n int, err error) {
37-
return defaultOutput.Print(w, a...)
38-
}
39-
40-
func Println(w io.Writer, a ...interface{}) (n int, err error) {
41-
return defaultOutput.Println(w, a...)
42-
}
43-
44-
func Printf(w io.Writer, format string, args ...interface{}) (n int, err error) {
45-
return defaultOutput.Printf(w, format, args...)
46-
}
47-
48-
func NewOutput() *Output {
49-
return &Output{}
50-
}
51-
52-
type Output struct {
53-
}
54-
55-
func (o *Output) Print(w io.Writer, a ...interface{}) (n int, err error) {
5636
return fmt.Fprint(w, a...)
5737
}
5838

59-
func (o *Output) Println(w io.Writer, a ...interface{}) (n int, err error) {
39+
func Println(w io.Writer, a ...interface{}) (n int, err error) {
6040
return fmt.Fprintln(w, a...)
6141
}
6242

63-
func (o *Output) Printf(w io.Writer, format string, a ...interface{}) (n int, err error) {
43+
func Printf(w io.Writer, format string, a ...interface{}) (n int, err error) {
6444
return fmt.Fprintf(w, format, a...)
6545
}

cli/output_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -44,20 +44,19 @@ func TestDefaultWriter(t *testing.T) {
4444

4545
func TestOutput(t *testing.T) {
4646
w := new(bytes.Buffer)
47-
output := new(Output)
48-
index, err := output.Print(w, "who are you")
47+
index, err := Print(w, "who are you")
4948
assert.Equal(t, 11, index)
5049
assert.Nil(t, err)
5150
assert.Equal(t, "who are you", w.String())
5251

5352
w.Reset()
54-
index, err = output.Println(w, "I am MrX")
53+
index, err = Println(w, "I am MrX")
5554
assert.Equal(t, 9, index)
5655
assert.Nil(t, err)
5756
assert.Equal(t, "I am MrX\n", w.String())
5857

5958
w.Reset()
60-
index, err = output.Printf(w, "and you%s", "?")
59+
index, err = Printf(w, "and you%s", "?")
6160
assert.Equal(t, 8, index)
6261
assert.Nil(t, err)
6362
assert.Equal(t, "and you?", w.String())

0 commit comments

Comments
 (0)