2016-11-07 20 views
-3

打開的文件可以說我有這樣的代碼:golang - 在一個空的bash窗口

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)) 
} 
go run運行時,它

我希望它在清除的bash窗口寫入。是否可以在不使用任何其他開放源代碼存儲庫的情況下這樣做?

在此先感謝。

+5

你是什麼意思寫在一個清除的緩衝區? – jcbwlkr

+0

我編輯了這個問題。 – Paul

+4

[我怎樣才能清除Go中的終端屏幕?](http://stackoverflow.com/questions/22891644/how-can-i-clear-the-terminal-screen-in-go);和[我怎樣才能清除控制檯與golang在Windows?](http://stackoverflow.com/questions/19209425/how-i-clear-the-console-with-golang-in-windows) – icza

回答

1

如果清除該終端確實是你的程序的責任的一部分,然後檢查答案在這個問題How can I clear the terminal screen in Go?

但是如果你只是想清除屏幕作爲開發過程的一部分,那麼我會保持簡單和做這樣的事情

clear && go run *.go