Files
blog/write-go/_fix_inline.py
T
2026-06-01 17:57:22 +08:00

17 lines
656 B
Python

p = r"E:\GitHub\blog\write-go\cmd\writeserver\main.go"
with open(p, "r", encoding="utf-8") as f:
c = f.read()
# Replace: lg = logutil.Logger
# With: lg = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo})).With("svc", "writeserver")
old = "lg = logutil.Logger"
new = 'lg = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo})).With("svc", "writeserver")'
c = c.replace(old, new)
# Also remove logutil import if present
c = c.replace('\t"write-server/internal/logutil"\n', '')
with open(p, "w", encoding="utf-8", newline="\n") as f:
f.write(c)
print("Fixed: inline slog init")