GO語言"archive/zip"包中"Reader"類型的用法及代碼示例。
閱讀器提供來自 ZIP 存檔的內容。
用法:
type Reader struct {
File []*File
Comment string
// contains filtered or unexported fields
}
例子:
package main
import (
"archive/zip"
"fmt"
"io"
"log"
"os"
)
func main() {
// Open a zip archive for reading.
r, err := zip.OpenReader("testdata/readme.zip")
if err != nil {
log.Fatal(err)
}
defer r.Close()
// Iterate through the files in the archive,
// printing some of their contents.
for _, f := range r.File {
fmt.Printf("Contents of %s:\n", f.Name)
rc, err := f.Open()
if err != nil {
log.Fatal(err)
}
_, err = io.CopyN(os.Stdout, rc, 68)
if err != nil {
log.Fatal(err)
}
rc.Close()
fmt.Println()
}
}
輸出:
Contents of README: This is the source code repository for the Go programming language.
相關用法
- GO Reader.Multistream用法及代碼示例
- GO Reader.Len用法及代碼示例
- GO Reader.ReadAll用法及代碼示例
- GO ReadMessage用法及代碼示例
- GO Read用法及代碼示例
- GO ReadFile用法及代碼示例
- GO ReadAtLeast用法及代碼示例
- GO ReadDir用法及代碼示例
- GO ReadFull用法及代碼示例
- GO ReadAll用法及代碼示例
- GO Regexp.FindString用法及代碼示例
- GO Regexp.FindAllIndex用法及代碼示例
- GO ResponseRecorder用法及代碼示例
- GO ReverseBytes64用法及代碼示例
- GO ReverseBytes16用法及代碼示例
- GO Regexp.ReplaceAllLiteralString用法及代碼示例
- GO Regexp.FindStringSubmatch用法及代碼示例
- GO Regexp.FindAllString用法及代碼示例
- GO Regexp.ExpandString用法及代碼示例
- GO ResponseWriter用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Reader。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。