style: add blank lines between declarations and statement blocks

Separate top-level declarations and multi-line statements with blank
lines, keeping an "if err != nil" check next to the statement it
belongs to. Expand semicolon one-liners, group the nativeTransport
fields by purpose, and format the cgo preamble as readable C.
Apart from the expanded one-liners and the C preamble, the change
is whitespace only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-12-03 18:36:19 +01:00
1 parent ec0297fd23
commit a6fda8f8d3
25 files changed
+929 -41

No files matched your search

+24
View File
@@ -46,21 +46,26 @@ func run(ctx context.Context, args []string, out, log io.Writer) error {
if len(args) == 0 {
return errors.New(usage)
}
if args[0] == "help" || args[0] == "--help" || args[0] == "-h" {
fmt.Fprintln(out, usage)
return nil
}
if args[0] == "doctor" {
if len(args) != 1 {
return errors.New(usage)
}
return doctor(ctx, out, log)
}
switch args[0] {
case "inspect", "sync", "finalize", "status":
default:
return errors.New(usage)
}
flags := flag.NewFlagSet(args[0], flag.ContinueOnError)
flags.SetOutput(log)
configPath := flags.String("config", "", "JSON migration configuration")
@@ -70,62 +75,79 @@ func run(ctx context.Context, args []string, out, log io.Writer) error {
if errors.Is(err, flag.ErrHelp) {
return nil
}
return err
}
if flags.NArg() != 0 {
return errors.New("unexpected positional arguments")
}
if args[0] == "status" {
if *statePath == "" {
return errors.New("--state is required")
}
s, err := migration.LoadState(*statePath)
if err != nil {
return err
}
return json.NewEncoder(out).Encode(s)
}
if *configPath == "" {
return errors.New("--config is required")
}
c, err := migration.ReadConfig(*configPath)
if err != nil {
return err
}
process := migration.Process{Stderr: log}
if args[0] != "inspect" && *statePath == "" {
return errors.New("--state is required")
}
if args[0] == "finalize" && !*stopped {
return errors.New("finalize requires --writers-stopped; stop and flush all application writers first")
}
if args[0] != "finalize" && *stopped {
return errors.New("--writers-stopped is only valid with finalize")
}
if c.Backend != "native" && args[0] != "inspect" {
if _, err = exec.LookPath("rsync"); err != nil {
return fmt.Errorf("rsync is required: %w", err)
}
}
engine, closeEngine, err := migration.NewEngine(ctx, c, process, log)
if err != nil {
return err
}
defer closeEngine.Close()
if args[0] == "inspect" {
info, err := engine.Inspect(ctx, c)
if err != nil {
return err
}
return json.NewEncoder(out).Encode(info)
}
if err = engine.Sync(ctx, c, *statePath, args[0] == "finalize"); err != nil {
return err
}
s, err := migration.LoadState(*statePath)
if err != nil {
return err
}
return json.NewEncoder(out).Encode(s)
}
@@ -138,6 +160,7 @@ func doctor(ctx context.Context, out, log io.Writer) error {
{"docker", []string{"compose", "version"}},
{"docker", []string{"info", "--format", "Docker server: {{.ServerVersion}}"}},
}
for _, check := range checks {
checkCtx, cancel := context.WithTimeout(ctx, 15*time.Second)
cmd := exec.CommandContext(checkCtx, check.name, check.args...)
@@ -148,5 +171,6 @@ func doctor(ctx context.Context, out, log io.Writer) error {
return fmt.Errorf("check %s: %w", check.name, err)
}
}
return nil
}