It's theoretically possible to change the behavior of
Scanf by hotswapping the value of
os.Stdin with some other
os.File. I wouldn't particularly recommend it just for testing purposes, though.
A better option would just be to make your
Init take in an
io.Reader that you pass to
Overall, however, it would likely be better to separate your device initialization code from your input as much as possible. This probably means having a device list returning function and a device opening function. You only need to prompt for selection in live/main code.