Standard library / compress/bzip2
compress/bzip2.StructuralError
Represents a malformed BZIP2 stream structure. Use errors.As to distinguish the error type from I/O failures. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type StructuralError stringWorking Example
Example Snippetgo
package main
import ( "compress/bzip2" "errors" "fmt" "io" "strings")
func must(e error) { if e != nil { panic(e) }}
func main() { r := bzip2.NewReader(strings.NewReader("not bzip2")) _, e := io.ReadAll(r) var bad bzip2.StructuralError fmt.Println(errors.As(e, &bad))}