1
0
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:
Sebastiaan van Stijn
2026-02-08 15:45:59 +01:00
parent 34805dd013
commit 39e82e6524
2 changed files with 14 additions and 14 deletions

View File

@@ -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
}

View File

@@ -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
}