Files
blog/write-go/_fix_slog.py
T

13 lines
358 B
Python
Raw Normal View History

2026-06-01 17:57:22 +08:00
p = r"E:\GitHub\blog\write-go\cmd\writeserver\main.go"
with open(p, "r", encoding="utf-8") as f:
c = f.read()
# Need "log/slog" import. It was removed when "log" was dropped.
c = c.replace(
'"encoding/json"',
'"log/slog"\n\t"encoding/json"'
)
with open(p, "w", encoding="utf-8", newline="\n") as f:
f.write(c)
print("Added slog import")