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

This commit is contained in:
2022-09-10 02:36:18 +08:00
parent 95ff3dabab
commit bcc99e523e

View File

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