草庐IT

go - 使用 flate.NewWriterDict 的压缩很奇怪

问题第一道工序compressed_1:[]byte{0xf2,0x48,0xcd,0xc9,0xc9,0x7,0x0}第二个过程(用字典压缩)compressed_2:[]byte{0x2,0x13,0x0,0x0}但我期待compressed_2:[]byte{0xf2,0x0,0x11,0x0,0x0}我的期望基于以下内容。https://www.rfc-editor.org/rfc/rfc7692#section-7.2.3.2python的其他实现已经确认它们将使用上述正确结果进行压缩。https://github.com/aaugustin/websockets不知道是go

go - “r.(flate.Reader)”在golang的zlib/reader.go文件中是什么意思?

我在golang的zlib/reader.go文件中找到了很多像r.(flate.Reader)这样的代码片段。这是什么意思?https://golang.org/src/compress/zlib/reader.gofunc(z*reader)Reset(rio.Reader,dict[]byte)error{iffr,ok:=r.(flate.Reader);ok{z.r=fr}else{z.r=bufio.NewReader(r)}//morecodeomitted...}附言io和flate的源代码。io:https://golang.org/src/io/io.goFlate