From e53f7b54360d9162c0ab3f0f726f8574a90d06a7 Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Fri, 17 Jul 2026 02:03:39 +0100 Subject: [PATCH] sumn light --- TerminalLineRecorder/main.go | 48 +++++++++++++++++++++++++++++++++++- go.mod | 9 +++---- go.sum | 4 --- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/TerminalLineRecorder/main.go b/TerminalLineRecorder/main.go index 38dd16d..d34eb62 100644 --- a/TerminalLineRecorder/main.go +++ b/TerminalLineRecorder/main.go @@ -1,3 +1,49 @@ package main -func main() {} +import ( + "bufio" + "fmt" + "os" + "path/filepath" + "strings" + + "golang.org/x/term" +) + +func main() { + // Create a reader + reader := bufio.NewReader(os.Stdin) + + //Create a file path: + err := os.Mkdir("./Log", os.ModePerm) + + check(err) + + path := filepath.Join("./Log", "TerminalLog.txt") + file, _ := os.Create(path) // Creating the file and assinging it the variable file + + // Create a writer + writer := bufio.NewWriter(file) + + // The rest. + fmt.Println("Enter in commands you were to run in the terminal, this go file acts as a middle man recorder: \n") + input, _ := reader.ReadString('.') + + var inputs []string + + cleanedInput := strings.Split(inputs, "\n") + + writer.WriteString(cleanedInput) + + term.NewTerminal(_, input) * Terminal + + defer writer.Flush() + defer file.Close() + +} + +func check(e error) { + if e != nil { + panic(e) + } +} diff --git a/go.mod b/go.mod index 8cc4c18..c818f50 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,6 @@ module LearningGo go 1.26.5 -require ( - github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef // indirect - golang.org/x/crypto v0.54.0 // indirect - golang.org/x/sys v0.47.0 // indirect - golang.org/x/term v0.45.0 // indirect -) +require golang.org/x/term v0.45.0 + +require golang.org/x/sys v0.47.0 // indirect diff --git a/go.sum b/go.sum index 8730a1a..d2468be 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,3 @@ -github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef h1:A9HsByNhogrvm9cWb28sjiS3i7tcKCkflWFEkHfuAgM= -github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= -golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= -golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=