mirror of
https://github.com/docker/cli.git
synced 2026-10-31 11:35:26 +03:00
cli/streams: move constructors to the start
It's more idiomatic to define the constructor before methods. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -15,6 +15,13 @@ type In struct {
|
||||
in io.ReadCloser
|
||||
}
|
||||
|
||||
// NewIn returns a new [In] from an [io.ReadCloser].
|
||||
func NewIn(in io.ReadCloser) *In {
|
||||
i := &In{in: in}
|
||||
i.fd, i.isTerminal = term.GetFdInfo(in)
|
||||
return i
|
||||
}
|
||||
|
||||
// Read implements the [io.Reader] interface.
|
||||
func (i *In) Read(p []byte) (int, error) {
|
||||
return i.in.Read(p)
|
||||
@@ -47,10 +54,3 @@ func (i *In) CheckTty(attachStdin, ttyMode bool) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewIn returns a new [In] from an [io.ReadCloser].
|
||||
func NewIn(in io.ReadCloser) *In {
|
||||
i := &In{in: in}
|
||||
i.fd, i.isTerminal = term.GetFdInfo(in)
|
||||
return i
|
||||
}
|
||||
|
||||
@@ -15,6 +15,13 @@ type Out struct {
|
||||
out io.Writer
|
||||
}
|
||||
|
||||
// NewOut returns a new [Out] from an [io.Writer].
|
||||
func NewOut(out io.Writer) *Out {
|
||||
o := &Out{out: out}
|
||||
o.fd, o.isTerminal = term.GetFdInfo(out)
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Out) Write(p []byte) (int, error) {
|
||||
return o.out.Write(p)
|
||||
}
|
||||
@@ -44,10 +51,3 @@ func (o *Out) GetTtySize() (height uint, width uint) {
|
||||
}
|
||||
return uint(ws.Height), uint(ws.Width)
|
||||
}
|
||||
|
||||
// NewOut returns a new [Out] from an [io.Writer].
|
||||
func NewOut(out io.Writer) *Out {
|
||||
o := &Out{out: out}
|
||||
o.fd, o.isTerminal = term.GetFdInfo(out)
|
||||
return o
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user