Files
zeekay ad03733525 module: hanzo.ai/lz4/v4
The repo moved to the hanzo-go org; the import path did not move with it, which
is the point of a vanity path — a consumer pins hanzo.ai/lz4/v4 and never learns
which org holds the git repo.

The /v4 rides along unchanged. A major-version suffix is part of the MODULE path
by Go's own rule and was never part of the repo name, which is why the vanity
list could not express this module until repoOf learned to take the path's first
segment as the repo.
2026-08-27 12:43:32 -07:00

73 lines
1.2 KiB
Go

//+build ignore
package main
import (
"bytes"
"fmt"
"io"
"log"
"os"
"hanzo.ai/lz4/v4/internal/lz4block"
"github.com/pierrec/packer"
"golang.org/x/tools/imports"
)
type DescriptorFlags struct {
// FLG
_ [2]int
ContentChecksum [1]bool
Size [1]bool
BlockChecksum [1]bool
BlockIndependence [1]bool
Version [2]uint16
// BD
_ [4]int
BlockSizeIndex [3]lz4block.BlockSizeIndex
_ [1]int
}
type DataBlockSize struct {
size [31]int
Uncompressed bool
}
func main() {
err := do()
if err != nil {
log.Fatal(err)
}
}
func do() error {
out, err := os.Create("frame_gen.go")
if err != nil {
return err
}
defer out.Close()
pkg := "lz4stream"
buf := new(bytes.Buffer)
for i, t := range []interface{}{
DescriptorFlags{}, DataBlockSize{},
} {
if i > 0 {
pkg = ""
}
err := packer.GenPackedStruct(buf, &packer.Config{PkgName: pkg}, t)
if err != nil {
return fmt.Errorf("%T: %v", t, err)
}
}
// Resolve imports.
code, err := imports.Process("", buf.Bytes(), nil)
if err != nil {
// Output without imports.
_, _ = io.Copy(out, buf)
return err
}
_, err = io.Copy(out, bytes.NewReader(code))
return err
}