From 39e82e6524ab0897cd1ca3aa454bc158cc4a5494 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 8 Feb 2026 15:45:59 +0100 Subject: [PATCH] cli/streams: move constructors to the start It's more idiomatic to define the constructor before methods. Signed-off-by: Sebastiaan van Stijn --- cli/streams/in.go | 14 +++++++------- cli/streams/out.go | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cli/streams/in.go b/cli/streams/in.go index f5cfce6ba1..b7175ae087 100644 --- a/cli/streams/in.go +++ b/cli/streams/in.go @@ -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 -} diff --git a/cli/streams/out.go b/cli/streams/out.go index 12e410e186..cce0e47cc0 100644 --- a/cli/streams/out.go +++ b/cli/streams/out.go @@ -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 -}