go - Golang - Read Os.stdin input but don't echo it -


in golang program i'm reading os.stdin input bufio.reader.

after enter pressed, program reads input , printed onto console. possible not print input onto console? after reading it, process input , reprint (and no longer need original input).

i read data this:

inputreader := bufio.newreader(os.stdin) {     outgoing, _ := inputreader.readstring('\n')     outs <- outgoing } 

i cannot think other methods use ansi escape codes clear terminal , move cursor specific location (in case column 1:row 1).

var screen *bytes.buffer = new(bytes.buffer) var output *bufio.writer = bufio.newwriter(os.stdout) 

and here basic helper methods ease job working terminal.

// move cursor given position func movecursor(x int, y int) {     fmt.fprintf(screen, "\033[%d;%dh", x, y) }  // clear terminal func clearterminal() {     output.writestring("\033[2j") } 

then inside function need clear terminal , move cursor first column , first row of terminal window. @ end have output computed result.

for {     outgoing, err := input.readstring('\n')      if err != nil {         break     }      if _, err := fmt.sscanf(outgoing, "%f", input); err != nil {         fmt.println("input error!")         continue     }      // clear console     clearterminal()     movecursor(1,1)      fmt.println(outs) // prints computed result } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -