亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
archive archive/tar archive/zip bufio bufio(緩存) builtin builtin(內(nèi)置包) bytes bytes(包字節(jié)) compress compress/bzip2(壓縮/bzip2) compress/flate(壓縮/flate) compress/gzip(壓縮/gzip) compress/lzw(壓縮/lzw) compress/zlib(壓縮/zlib) container container/heap(容器數(shù)據(jù)結(jié)構(gòu)heap) container/list(容器數(shù)據(jù)結(jié)構(gòu)list) container/ring(容器數(shù)據(jù)結(jié)構(gòu)ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(數(shù)據(jù)庫(kù)/sql) database/sql/driver(數(shù)據(jù)庫(kù)/sql/driver) debug debug/dwarf(調(diào)試/dwarf) debug/elf(調(diào)試/elf) debug/gosym(調(diào)試/gosym) debug/macho(調(diào)試/macho) debug/pe(調(diào)試/pe) debug/plan9obj(調(diào)試/plan9obj) encoding encoding(編碼) encoding/ascii85(編碼/ascii85) encoding/asn1(編碼/asn1) encoding/base32(編碼/base32) encoding/base64(編碼/base64) encoding/binary(編碼/binary) encoding/csv(編碼/csv) encoding/gob(編碼/gob) encoding/hex(編碼/hex) encoding/json(編碼/json) encoding/pem(編碼/pem) encoding/xml(編碼/xml) errors errors(錯(cuò)誤) expvar expvar flag flag(命令行參數(shù)解析flag包) fmt fmt go go/ast(抽象語(yǔ)法樹(shù)) go/build go/constant(常量) go/doc(文檔) go/format(格式) go/importer go/parser go/printer go/scanner(掃描儀) go/token(令牌) go/types(類型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(圖像) image/color(顏色) image/color/palette(調(diào)色板) image/draw(繪圖) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系統(tǒng)) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路徑) plugin plugin(插件) reflect reflect(反射) regexp regexp(正則表達(dá)式) regexp/syntax runtime runtime(運(yùn)行時(shí)) runtime/debug(調(diào)試) runtime/internal/sys runtime/pprof runtime/race(競(jìng)爭(zhēng)) runtime/trace(執(zhí)行追蹤器) sort sort(排序算法) strconv strconv(轉(zhuǎn)換) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系統(tǒng)調(diào)用) testing testing(測(cè)試) testing/iotest testing/quick text text/scanner(掃描文本) text/tabwriter text/template(定義模板) text/template/parse time time(時(shí)間戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
文字

  • import "compress/zlib"

  • 概述

  • 索引

  • 示例

概述

打包 zlib 實(shí)現(xiàn)了讀取和寫(xiě)入zlib格式壓縮數(shù)據(jù),如 RFC 1950中所述。

實(shí)現(xiàn)提供了在讀取和壓縮期間解壓縮的過(guò)濾器。例如,要將壓縮數(shù)據(jù)寫(xiě)入緩沖區(qū):

var b bytes.Buffer
w := zlib.NewWriter(&b)w.Write([]byte("hello, world\n"))w.Close()

并讀回?cái)?shù)據(jù):

r, err := zlib.NewReader(&b)io.Copy(os.Stdout, r)r.Close()

參數(shù)

  • Constants(常量)

  • Variables(變量)

  • func NewReader(r io.Reader) (io.ReadCloser, error)

  • func NewReaderDict(r io.Reader, dict []byte) (io.ReadCloser, error)

  • type Resetter

  • type Writer

  • func NewWriter(w io.Writer) *Writer

  • func NewWriterLevel(w io.Writer, level int) (*Writer, error)

  • func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*Writer, error)

  • func (z *Writer) Close() error

  • func (z *Writer) Flush() error

  • func (z *Writer) Reset(w io.Writer)

  • func (z *Writer) Write(p []byte) (n int, err error)

示例

NewReader NewWriter

打包文件

reader.go writer.go

常量

這些常量是從 flate 包中復(fù)制的,因此導(dǎo)入“compress/zlib”的代碼不需要導(dǎo)入“compress/flate”。

const (
        NoCompression      = flate.NoCompression
        BestSpeed          = flate.BestSpeed
        BestCompression    = flate.BestCompression
        DefaultCompression = flate.DefaultCompression
        HuffmanOnly        = flate.HuffmanOnly)

變量

var (        // 讀取具有無(wú)效校驗(yàn)和的ZLIB數(shù)據(jù)時(shí)會(huì)返回ErrChecksum。
        ErrChecksum = errors.New("zlib: invalid checksum")        // 讀取具有無(wú)效字典的ZLIB數(shù)據(jù)時(shí),會(huì)返回ErrDictionary。
        ErrDictionary = errors.New("zlib: invalid dictionary")        // 讀取包含無(wú)效標(biāo)題的ZLIB數(shù)據(jù)時(shí),會(huì)返回ErrHeader。
        ErrHeader = errors.New("zlib: invalid header"))

func NewReader

func NewReader(r io.Reader) (io.ReadCloser, error)

NewReader 創(chuàng)建一個(gè)新的 ReadCloser。從返回的 ReadCloser 讀取并解壓縮來(lái)自r的數(shù)據(jù)。如果 r 沒(méi)有實(shí)現(xiàn) io.ByteReader,解壓縮程序可能會(huì)讀取比r更多的數(shù)據(jù)。調(diào)用者有責(zé)任在完成時(shí)調(diào)用ReadCloser 上的 Close。

NewReader 返回的 ReadCloser 也實(shí)現(xiàn)了 Resetter。

示例

package mainimport ("bytes""compress/zlib""io""os")func main() {
	buff := []byte{120, 156, 202, 72, 205, 201, 201, 215, 81, 40, 207,47, 202, 73, 225, 2, 4, 0, 0, 255, 255, 33, 231, 4, 147}
	b := bytes.NewReader(buff)

	r, err := zlib.NewReader(b)if err != nil {panic(err)}
	io.Copy(os.Stdout, r)

	r.Close()}

func NewReaderDict

func NewReaderDict(r io.Reader, dict []byte) (io.ReadCloser, error)

NewReaderDict 與 NewReader 類似,但使用預(yù)設(shè)字典。如果壓縮數(shù)據(jù)沒(méi)有引用它,NewReaderDict 會(huì)忽略該字典。如果壓縮數(shù)據(jù)引用不同的字典,則 NewReaderDict 返回 ErrDictionary。

NewReaderDict 返回的 ReadCloser 也實(shí)現(xiàn)了 Resetter。

type Resetter

重置器重置由 NewReader 或 NewReaderDict 返回的 ReadCloser 以切換到新的底層 Reader。這允許重新使用 ReadCloser 而不是分配新的。

type Resetter interface {        // 重置會(huì)丟棄任何緩沖數(shù)據(jù),并將重置器重置為好像它一樣        // 最新與給定的讀者初始化。        Reset(r io.Reader, dict []byte) error}

type Writer

Writer 將寫(xiě)入數(shù)據(jù)的數(shù)據(jù)寫(xiě)入底層寫(xiě)入器(請(qǐng)參閱 NewWriter)。

type Writer struct {        // 包含過(guò)濾或未導(dǎo)出的字段}

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter 創(chuàng)建一個(gè)新的 Writer。寫(xiě)入返回的 Writer 被壓縮并寫(xiě)入 w。

調(diào)用者有責(zé)任在完成時(shí)調(diào)用 WriteCloser 上的 Close。寫(xiě)入可能會(huì)被緩沖,直到關(guān)閉才會(huì)被刷新。

示例

package mainimport ("bytes""compress/zlib""fmt")func main() {var b bytes.Buffer

	w := zlib.NewWriter(&b)
	w.Write([]byte("hello, world\n"))
	w.Close()
	fmt.Println(b.Bytes())}

func NewWriterLevel

func NewWriterLevel(w io.Writer, level int) (*Writer, error)

NewWriterLevel 就像 NewWriter,但指定壓縮級(jí)別而不是假設(shè) DefaultCompression。

壓縮級(jí)別可以是DefaultCompression,NoCompression, HuffmanOnly 或 BestSpeed 和 BestCompression 之間的任何整數(shù)值。如果級(jí)別有效,返回的錯(cuò)誤將為零。

func NewWriterLevelDict

func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*Writer, error)

NewWriterLevelDict 與 NewWriterLevel 類似,但指定要壓縮的字典。

字典可能是零。如果沒(méi)有,則在 Writer 關(guān)閉之前不應(yīng)修改其內(nèi)容。

func (*Writer) Close

func (z *Writer) Close() error

關(guān)閉Writer,將任何未寫(xiě)入的數(shù)據(jù)刷新到基礎(chǔ) io.Writer,但不關(guān)閉基礎(chǔ) io.Writer。

func (*Writer) Flush

func (z *Writer) Flush() error

Flush Writer 到其基礎(chǔ) io.Writer。

func (*Writer) Reset

func (z *Writer) Reset(w io.Writer)

重置清除Writer z 的狀態(tài),使其等于 NewWriterLevel 或 NewWriterLevelDict 的初始狀態(tài),并且寫(xiě)入 w。

func (*Writer) Write

func (z *Writer) Write(p []byte) (n int, err error)

寫(xiě)入一個(gè)壓縮形式的 p 到底層的 io.Writer 。在寫(xiě)入器關(guān)閉或明確刷新之前,壓縮的字節(jié)不一定會(huì)被刷新。

上一篇: 下一篇: