refactor: extract internal/session and eliminate I/O globals

Move serial port, trzsz filter, and pipe lifecycle into
internal/session.SerialSession. Replace 8 global I/O vars
(serialPort, trzszFilter, stdinPipe, stdoutPipe, clientIn,
clientOut, termch, termchOnce) with single sess variable.
Delete utils.go.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
JiXieShi
2026-05-23 21:49:43 +08:00
parent 31dd9da490
commit a1524a7e17
7 changed files with 165 additions and 137 deletions
+5 -1
View File
@@ -6,13 +6,17 @@ import (
"testing"
"github.com/jixishi/SerialTerminalForWindowsTerminal/internal/event"
"github.com/jixishi/SerialTerminalForWindowsTerminal/internal/session"
"github.com/jixishi/SerialTerminalForWindowsTerminal/pkg/forward"
"github.com/jixishi/SerialTerminalForWindowsTerminal/pkg/luaplugin"
)
func setupTestPipes() {
if sess == nil {
sess = &session.SerialSession{}
}
var cr *io.PipeReader
cr, stdinPipe = io.Pipe()
cr, sess.StdinPipe = io.Pipe()
go func() {
buf := make([]byte, 4096)
for {