Use ioutil.ReadAll() to read from stdin

This commit is contained in:
James Mills 2017-06-03 19:33:44 +01:00
parent 38081670a6
commit 3e1359d617
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -4,6 +4,7 @@ import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
@ -49,8 +50,7 @@ func publish(topic string, message string) {
if message == "" || message == "-" {
log.Printf("Reading message from stdin...\n")
buf := make([]byte, 1024)
_, err := os.Stdin.Read(buf)
buf, err := ioutil.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}