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

28 lines
550 B

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