Standard library / archive/zip
archive/zip.ErrAlgorithm
Unsupported ZIP compression method error when opening an entry. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrAlgorithm errorWorking Example
Example Snippetgo
package main
import ( "archive/zip" "bytes" "errors" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { var b bytes.Buffer w := zip.NewWriter(&b) f, e := w.CreateRaw(&zip.FileHeader{Name: "a", Method: 99}) must(e) _, e = f.Write(nil) must(e) must(w.Close()) r, e := zip.NewReader(bytes.NewReader(b.Bytes()), int64(b.Len())) must(e) _, e = r.File[0].Open() fmt.Println(errors.Is(e, zip.ErrAlgorithm))}