use different strategy from stackoverflow

This commit is contained in:
filifa 2024-08-25 22:00:01 -05:00
parent 583a50be79
commit f0b432614d
1 changed files with 3 additions and 5 deletions

View File

@ -47,13 +47,11 @@ func handleEvent(event sdl.Event, m *milkDropWindow) bool {
} }
func milkbucket(cmd *cobra.Command, args []string) { func milkbucket(cmd *cobra.Command, args []string) {
fi, err := os.Stdin.Stat() stat, err := os.Stdin.Stat()
if err != nil { if err != nil {
panic(err) panic(err)
} } else if (stat.Mode() & os.ModeCharDevice) != 0 {
size := fi.Size() log.Fatal("nothing to read from stdin")
if size <= 0 {
log.Fatal("stdin is empty")
} }
err = sdl.Init(sdl.INIT_VIDEO) err = sdl.Init(sdl.INIT_VIDEO)