From 0b6bec26adc8aa1558986d8eb07bcc54fe2fe610 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 26 Feb 2024 12:55:16 -0500 Subject: [PATCH 1/2] refactor(term): move conpty out of windows To match golang/sys, the windows package should contain Windows specific API calls. The conpty package is a high-level package that creates and manages ConPty sessions, and thus wouldn't make sense to keep it under windows. --- exp/term/conpty/conpty_other.go | 11 +++++++++++ exp/term/{windows => }/conpty/conpty_windows.go | 0 exp/term/{windows => }/conpty/doc.go | 5 +++++ exp/term/{windows => }/conpty/exec_windows.go | 0 4 files changed, 16 insertions(+) create mode 100644 exp/term/conpty/conpty_other.go rename exp/term/{windows => }/conpty/conpty_windows.go (100%) rename exp/term/{windows => }/conpty/doc.go (52%) rename exp/term/{windows => }/conpty/exec_windows.go (100%) diff --git a/exp/term/conpty/conpty_other.go b/exp/term/conpty/conpty_other.go new file mode 100644 index 00000000..3d51168a --- /dev/null +++ b/exp/term/conpty/conpty_other.go @@ -0,0 +1,11 @@ +package conpty + +// ConPty represents a Windows Console Pseudo-terminal. +// https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session#preparing-the-communication-channels +type ConPty struct{} + +// New creates a new ConPty. +// This function is not supported on non-Windows platforms. +func New(int, int, int) (*ConPty, error) { + return nil, ErrUnsupported +} diff --git a/exp/term/windows/conpty/conpty_windows.go b/exp/term/conpty/conpty_windows.go similarity index 100% rename from exp/term/windows/conpty/conpty_windows.go rename to exp/term/conpty/conpty_windows.go diff --git a/exp/term/windows/conpty/doc.go b/exp/term/conpty/doc.go similarity index 52% rename from exp/term/windows/conpty/doc.go rename to exp/term/conpty/doc.go index 49dc1f5b..60a2a353 100644 --- a/exp/term/windows/conpty/doc.go +++ b/exp/term/conpty/doc.go @@ -3,3 +3,8 @@ // https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session package conpty + +import "errors" + +// ErrUnsupported is returned when the current platform is not supported. +var ErrUnsupported = errors.New("conpty: unsupported platform") diff --git a/exp/term/windows/conpty/exec_windows.go b/exp/term/conpty/exec_windows.go similarity index 100% rename from exp/term/windows/conpty/exec_windows.go rename to exp/term/conpty/exec_windows.go From aedfff6d79955126d5500215ae0f9da7abf2a131 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 26 Feb 2024 15:44:34 -0500 Subject: [PATCH 2/2] Update exp/term/conpty/conpty_other.go --- exp/term/conpty/conpty_other.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exp/term/conpty/conpty_other.go b/exp/term/conpty/conpty_other.go index 3d51168a..7c176206 100644 --- a/exp/term/conpty/conpty_other.go +++ b/exp/term/conpty/conpty_other.go @@ -1,3 +1,6 @@ +//go:build !windows +// +build !windows + package conpty // ConPty represents a Windows Console Pseudo-terminal.