GO語言"bufio"包中"Writer"類型的用法及代碼示例。
Writer 為 io.Writer 對象實現緩衝。如果寫入 Writer 時發生錯誤,將不再接受任何數據,並且所有後續寫入和 Flush 都將返回錯誤。所有數據寫入完成後,客戶端應該調用 Flush 方法來保證所有數據都已經轉發到底層的 io.Writer。
用法:
type Writer struct {
// contains filtered or unexported fields
}
例子:
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
w := bufio.NewWriter(os.Stdout)
fmt.Fprint(w, "Hello, ")
fmt.Fprint(w, "world!")
w.Flush() // Don't forget to flush!
}
輸出:
Hello, world!
相關用法
- GO Writer.Init用法及代碼示例
- GO Writer.WriteAll用法及代碼示例
- GO Writer.RegisterCompressor用法及代碼示例
- GO Writer用法及代碼示例
- GO Writer.AvailableBuffer用法及代碼示例
- GO WriteFile用法及代碼示例
- GO WriteString用法及代碼示例
- GO Write用法及代碼示例
- GO WithDeadline用法及代碼示例
- GO WordEncoder.Encode用法及代碼示例
- GO WaitGroup用法及代碼示例
- GO WordDecoder.Decode用法及代碼示例
- GO WordDecoder.DecodeHeader用法及代碼示例
- GO WithValue用法及代碼示例
- GO WalkDir用法及代碼示例
- GO WithTimeout用法及代碼示例
- GO WithCancel用法及代碼示例
- GO Walk用法及代碼示例
- GO PutUvarint用法及代碼示例
- GO Scanner.Scan用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Writer。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。