Skip to content

Commit 094076b

Browse files
committed
refactor: strict exported-above-unexported ordering (fat12, images handler)
Two declaration-order fixes for the "exported above unexported" rule that #67's follow-up (8518acf) left, both respecting "const block at top (after imports)": - metadata/fat12.go: hoist exported CreateFAT12 above newFAT12Builder + the fat12Builder method group. - cmd/images/handler.go: keep the mixed const block at top (config.go-style const-first, since it holds a plain const + typed enum values), then hoist exported Handler above the unexported imageType/importSourceKind/importLocalPlan. Pure relocation, no behavior change. Verified project-wide: 0 exported-standalone- after-unexported, 0 exported-type-after-unexported, 0 AST layout violations across 236 files; const/var blocks at top everywhere except the SKILL-sanctioned typed-const grouping (type X then its const block). build/vet/lint (darwin+linux) + race tests green.
1 parent 8518acf commit 094076b

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

cmd/images/handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ package images
22

33
import cmdcore "github.com/cocoonstack/cocoon/cmd/core"
44

5-
type imageType int
6-
7-
type importSourceKind int
8-
95
const (
106
// digestDisplayLen = len("sha256:") + 12 hex digits for compact display.
117
digestDisplayLen = 19
@@ -22,6 +18,10 @@ type Handler struct {
2218
cmdcore.BaseHandler
2319
}
2420

21+
type imageType int
22+
23+
type importSourceKind int
24+
2525
type importLocalPlan struct {
2626
kind importSourceKind
2727
files []string

metadata/fat12.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ type fat12Builder struct {
4343
shortSeq int // counter for ~N short-name suffixes
4444
}
4545

46+
// CreateFAT12 streams a 1 MiB FAT12 image with VFAT long-filename support to w.
47+
// label is the volume label (e.g. "CIDATA"); files maps filename → content.
48+
func CreateFAT12(w io.Writer, label string, files map[string][]byte) error {
49+
b := newFAT12Builder(label)
50+
51+
for _, name := range slices.Sorted(maps.Keys(files)) {
52+
if err := b.addFile(name, files[name]); err != nil {
53+
return err
54+
}
55+
}
56+
return b.writeTo(w)
57+
}
58+
4659
func newFAT12Builder(label string) *fat12Builder {
4760
b := &fat12Builder{
4861
label: label,
@@ -195,19 +208,6 @@ func (b *fat12Builder) makeBootSector() []byte {
195208
return boot
196209
}
197210

198-
// CreateFAT12 streams a 1 MiB FAT12 image with VFAT long-filename support to w.
199-
// label is the volume label (e.g. "CIDATA"); files maps filename → content.
200-
func CreateFAT12(w io.Writer, label string, files map[string][]byte) error {
201-
b := newFAT12Builder(label)
202-
203-
for _, name := range slices.Sorted(maps.Keys(files)) {
204-
if err := b.addFile(name, files[name]); err != nil {
205-
return err
206-
}
207-
}
208-
return b.writeTo(w)
209-
}
210-
211211
// setFATEntry writes a 12-bit value into the FAT at the given cluster index.
212212
func setFATEntry(fat []byte, cluster int, val uint16) {
213213
off := cluster + cluster/2 //nolint:mnd

0 commit comments

Comments
 (0)