Browse Source

Fix(stdin-handler): Handle using reader instead of scanf

master
Samuel Pua 3 years ago
parent
commit
bcc99e523e
  1. 8
      cmd/messenger/main.go

8
cmd/messenger/main.go

@ -1,6 +1,7 @@
package main package main
import ( import (
"bufio"
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
@ -43,8 +44,12 @@ func main() {
func handleStdIn(webhookFlag *bool, webhookURL *string) { func handleStdIn(webhookFlag *bool, webhookURL *string) {
for { for {
var err error
var currStr string var currStr string
_, err := fmt.Scanln(&currStr)
reader := bufio.NewReader(os.Stdin)
for err == nil {
currStr, err = reader.ReadString('\n')
if err != nil { if err != nil {
return return
} }
@ -58,6 +63,7 @@ func handleStdIn(webhookFlag *bool, webhookURL *string) {
} }
} }
} }
}
func sendWebhook(currStr *string, webhookURL *string) error { func sendWebhook(currStr *string, webhookURL *string) error {
bodyReader := strings.NewReader(*currStr) bodyReader := strings.NewReader(*currStr)

Loading…
Cancel
Save