The core protocol of WoopChain
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.
 
 
 
woop/internal/blsgen/console.go

46 lines
926 B

package blsgen
import (
"bufio"
"fmt"
"os"
"strings"
)
var console consoleItf = &stdConsole{}
// consoleItf define the interface for module level console input and outputs
type consoleItf interface {
readPassword() (string, error)
readln() (string, error)
print(a ...interface{})
println(a ...interface{})
printf(format string, a ...interface{})
}
type stdConsole struct{}
func (console *stdConsole) readPassword() (string, error) {
return console.readln()
}
func (console *stdConsole) readln() (string, error) {
reader := bufio.NewReader(os.Stdin)
raw, err := reader.ReadString('\n')
if err != nil {
return "", err
}
return strings.TrimSpace(raw), nil
}
func (console *stdConsole) print(a ...interface{}) {
fmt.Print(a...)
}
func (console *stdConsole) println(a ...interface{}) {
fmt.Println(a...)
}
func (console *stdConsole) printf(format string, a ...interface{}) {
fmt.Printf(format, a...)
}