You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hal/hal/command_line_io.go

26 lines
434 B

package hal
import (
"fmt"
)
func NewCommandLineIO(index int) *CommandLineIO {
return &CommandLineIO{
index: index,
}
}
type CommandLineIO struct {
index int
}
func (io *CommandLineIO) Read() (result float64, err error) {
fmt.Printf("Input[%d]: ", io.index)
_, err = fmt.Scanf("%f", &result)
return
}
func (io *CommandLineIO) Write(output float64) error {
fmt.Printf("Output[%d]: %f\n", io.index, output)
return nil
}