Created
June 14, 2018 11:44
-
-
Save myitcv/0d0813e8cf04c9cf73bf7e23d266f4d1 to your computer and use it in GitHub Desktop.
Timed go get -u -v g golang.org/x/vgo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"os" | |
"os/exec" | |
"time" | |
) | |
func main() { | |
r, w := io.Pipe() | |
cmd := exec.Command("go", "get", "-v", "-u", "golang.org/x/vgo") | |
cmd.Stdout = w | |
cmd.Stderr = w | |
start := time.Now() | |
scanner := bufio.NewScanner(r) | |
go func() { | |
if err := cmd.Run(); err != nil { | |
panic(err) | |
} | |
w.Close() | |
}() | |
for scanner.Scan() { | |
fmt.Printf("%5.2fs: %v\n", time.Now().Sub(start).Seconds(), scanner.Text()) | |
} | |
if err := scanner.Err(); err != nil { | |
fmt.Fprintln(os.Stderr, "reading standard input:", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment