Skip to content

Commit

Permalink
Restore stdout capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoVictor committed Oct 23, 2024
1 parent 69416a4 commit 4af7662
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions container/templates/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ func executor(input Request) Response {
Value: input.Value,
}

// originalStdout := os.Stdout
// reader, writer, _ := os.Pipe()
// os.Stdout = writer
originalStdout := os.Stdout
reader, writer, _ := os.Pipe()
os.Stdout = writer

// channel := make(chan string)
channel := make(chan string)

// go func() {
// var buffer bytes.Buffer
// io.Copy(&buffer, reader)
// channel <- buffer.String()
// }()
go func() {
var buffer bytes.Buffer
io.Copy(&buffer, reader)
channel <- buffer.String()
}()

output, err := run(input.Value)

// writer.Close()
// os.Stdout = originalStdout
writer.Close()
os.Stdout = originalStdout

// response.Stdout = <-channel
response.Stdout = <-channel

if err != nil {
fmt.Println(err.Error())
Expand Down

0 comments on commit 4af7662

Please sign in to comment.