28 lines
728 B
Python
28 lines
728 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()
|
||
|
|
|
||
|
|
# Move lg.Info after config.Init() + recycle.InitRecycleBin()
|
||
|
|
old = '''func main() {
|
||
|
|
\tlg.Info("WriteServer starting")
|
||
|
|
\tconfig.Init()
|
||
|
|
\trecycle.InitRecycleBin()
|
||
|
|
|
||
|
|
\tgo autoStartBot()'''
|
||
|
|
|
||
|
|
new = '''func main() {
|
||
|
|
\tconfig.Init()
|
||
|
|
\trecycle.InitRecycleBin()
|
||
|
|
\tlg = logutil.Logger
|
||
|
|
\tlg.Info("WriteServer starting")
|
||
|
|
|
||
|
|
\tgo autoStartBot()'''
|
||
|
|
|
||
|
|
c = c.replace(old, new)
|
||
|
|
|
||
|
|
# Also remove the "var lg = logutil.Logger" at top level (now in main)
|
||
|
|
c = c.replace("var lg = logutil.Logger\n", "")
|
||
|
|
|
||
|
|
with open(p, "w", encoding="utf-8", newline="\n") as f:
|
||
|
|
f.write(c)
|
||
|
|
print("Fixed nil logger: lg.Info moved after config.Init()")
|