host icon indicating copy to clipboard operation
host copied to clipboard

fmt.Scanf fails after calling host.Init()

Open ABrilliantBeast opened this issue 5 months ago • 0 comments

Describe the bug Scanf fails after host.Init() called.

To Reproduce Steps to reproduce the behavior:

  1. Run program
package main

import (
	"fmt"
	"time"

	"periph.io/x/host/v3"
)

func main() {
	host.Init()

	fmt.Print("Enter times to flash: ")
	var repeat int
	_, err := fmt.Scanf("%d\n", &repeat)
	must("read values", err)
}

func must(m string, e error) {
	if e != nil {
		panic("failed to " + m + ": " + e.Error())
	}
}

  1. Run it.
  2. See output

Enter times to flash: panic: failed to read values: read /dev/stdin: bad file descriptor

Expected behavior fmt.Scanf returns without error and value set.

Platform (please complete the following information):

  • OS: Debian GNU/Linux 12
  • Board Raspberry Pi 5

Additional context If I remove the host.Init or call Scanf before it is called, it works fine

ABrilliantBeast avatar Jul 19 '25 14:07 ABrilliantBeast