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 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
} }
@@ -57,6 +62,7 @@ func handleStdIn(webhookFlag *bool, webhookURL *string) {
} }
} }
} }
}
} }
func sendWebhook(currStr *string, webhookURL *string) error { func sendWebhook(currStr *string, webhookURL *string) error {