lib/rac: fix example_test for Go 1.27 zlib encoder
diff --git a/lib/rac/example_test.go b/lib/rac/example_test.go index c5bb8d6..d65c096 100644 --- a/lib/rac/example_test.go +++ b/lib/rac/example_test.go
@@ -95,6 +95,9 @@ // // See the RAC specification for an explanation of the file format. func Example_indexLocationAtStart() { + // See "If printDetailedHexDumps was true..." below. + const printDetailedHexDumps = false + buf := &bytes.Buffer{} w := &rac.ChunkWriter{ Writer: buf, @@ -120,7 +123,9 @@ uint8(checksum>>16), uint8(checksum>>24), ) - fmt.Printf("Encoded dictionary resource:\n%s\n", hex.Dump(encodedDict)) + if printDetailedHexDumps { + fmt.Printf("Encoded dictionary resource:\n%s\n", hex.Dump(encodedDict)) + } dictResource, err := w.AddResource(encodedDict) if err != nil { @@ -148,7 +153,9 @@ log.Fatalf("AddChunk: %v", err) } - fmt.Printf("Encoded chunk #%d:\n%s\n", i, hex.Dump(encodedChunk)) + if printDetailedHexDumps { + fmt.Printf("Encoded chunk #%d:\n%s\n", i, hex.Dump(encodedChunk)) + } } if err := w.Close(); err != nil { @@ -156,7 +163,9 @@ } encoded := buf.Bytes() - fmt.Printf("RAC file:\n%s\n", hex.Dump(encoded)) + if printDetailedHexDumps { + fmt.Printf("RAC file:\n%s\n", hex.Dump(encoded)) + } // Decode the encoded bytes (the RAC-formatted bytes) to recover the // original "One sheep.\nTwo sheep\.Three sheep.\n" source. @@ -217,13 +226,20 @@ } } - // Note that these exact bytes depends on the zlib encoder's algorithm, but - // there is more than one valid zlib encoding of any given input. This - // "compare to golden output" test is admittedly brittle, as the standard - // library's zlib package's output isn't necessarily stable across Go - // releases. + // If printDetailedHexDumps was true then we'd also see this output below + // (between the ----) on Go 1.26, but slightly different output on Go 1.27 + // (released August 19, 2026). The exact bytes depends on the compress/zlib + // (or compress/flate) encoder's algorithm and there is more than one valid + // zlib encoding of any given input. + // + // https://go.dev/doc/go1.27#compressflatepkgcompressflate + // + // https://github.com/golang/go/commit/2747d887eb683f4fca0ed1350b3cc1aec860cf70 + // + // https://github.com/golang/go/commit/388145c51b0781594327b2646894dfaaaaaac0c6 - // Output: + // ---- + // Encoded dictionary resource: // 00000000 08 00 00 00 20 73 68 65 65 70 2e 0a d0 8d 7a 47 |.... sheep....zG| // @@ -251,7 +267,10 @@ // 00000080 01 01 00 00 ff ff 18 0c 03 a8 78 f9 0b e0 02 6e |..........x....n| // 00000090 0a c9 28 4a 4d 85 71 00 01 00 00 ff ff 21 6e 04 |..(JM.q......!n.| // 000000a0 66 |f| - // + + // ---- + + // Output: // Decoded: // [ 0, 11): One sheep. // [11, 22): Two sheep.