-2

lets say I have this code:

package main 

import (
     "io/ioutil" 
     "fmt"
)
func check(err error) {
     if err != nil {
         panic(err)
     }
} 
func main() {
     file, err := ioutil.ReadFile("test.txt")
     check(err)
     fmt.Print(string(file))
}

when running it with go run I want it to be written in a cleared bash window. Is it possible to do so without using any additional open-source repositories?

Thanks in advance.

  • 5
    What do you mean by written in a cleared buffer? – jcbwlkr Nov 07 '16 at 15:12
  • I've editted the question. –  Nov 07 '16 at 15:14
  • 4
    Possible duplicate of [How can I clear the terminal screen in Go?](http://stackoverflow.com/questions/22891644/how-can-i-clear-the-terminal-screen-in-go); and [How can I clear the console with golang in windows?](http://stackoverflow.com/questions/19209425/how-can-i-clear-the-console-with-golang-in-windows) – icza Nov 07 '16 at 15:18
  • You do it the same is you would in any language. See also https://stackoverflow.com/questions/2084508/clear-terminal-in-python – JimB Nov 07 '16 at 15:19

1 Answers1

1

If clearing the terminal is truly part of your program's responsibility then check out the answers in this question How can I clear the terminal screen in Go?

However if you're just wanting to clear the screen as part of your development process then I would keep it simple and do something like this

clear && go run *.go
Community
  • 1
  • 1
jcbwlkr
  • 7,789
  • 2
  • 22
  • 28