xalanq / cf-tool

:bar_chart: Codeforces CLI (Submit, Parse, Test, etc.). Support Contests, Gym, Groups, acmsguru, Windows, macOS, Linux, 7 MB
MIT License
1.3k stars 224 forks source link

Getting `cf test` to work with buffered output in Go. #150

Closed phea closed 2 years ago

phea commented 2 years ago

cf test does not capture the output when using buffered writer in Go. I use the following template for most of my code, is there a work around so I can continue using buffered io (for speed reasons) or do I switch to writing directly to standard input/output with fmt.Printf or something similar.

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()

    var T int
    fmt.Fscan(in, &T)
    for t := 0; t < T; t++ {
        // logic goes here
    }
}
phea commented 2 years ago

I was able to fix the issue by putting the go build command in the before script field of the config file.