Standard library / archive/zip

archive/zip.ErrChecksum

CRC mismatch sentinel encountered when entry is read through EOF. CRC is not cryptographic authentication. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
var ErrChecksum error

Working Example

Example Snippetgo
package main
import (  "archive/zip"  "bytes"  "errors"  "fmt"  "io")
func must(e error) {  if e != nil {    panic(e)  }}func archive() []byte {  var b bytes.Buffer  w := zip.NewWriter(&b)  f, e := w.CreateHeader(&zip.FileHeader{Name: "a.txt", Method: zip.Store})  must(e)  _, e = f.Write([]byte("Go"))  must(e)  must(w.Close())  return b.Bytes()}func main() {  b := archive()  r, e := zip.NewReader(bytes.NewReader(b), int64(len(b)))  must(e)  off, e := r.File[0].DataOffset()  must(e)  b[off] ^= 1  f, e := r.File[0].Open()  must(e)  _, e = io.ReadAll(f)  fmt.Println(errors.Is(e, zip.ErrChecksum))  must(f.Close())}
Go Reference