Skip to content

Commit 9dd2cec

Browse files
committed
ci(config): 更新配置解析逻辑以支持小写键名
ci(config): update config parsing logic to support lowercase keys
1 parent 85b6767 commit 9dd2cec

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.github/workflows/go-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535

3636
- name: Create test files
3737
run: |
38-
echo "Port=8080" > backup.conf
38+
echo "port=8080" > backup.conf
3939
echo "callback_secret=my-test-secret" >> backup.conf
40-
echo "ScriptPath=./test-script.sh" >> backup.conf
40+
echo "scriptpath=./test-script.sh" >> backup.conf
4141
echo "#!/bin/bash" > test-script.sh
4242
echo 'echo "script output"' >> test-script.sh
4343
chmod +x test-script.sh

go/callback/internal/config/config.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@ func LoadConfig(path string) (*Config, error) {
3636
continue
3737
}
3838

39-
// 查找 callback_secret
40-
if strings.HasPrefix(trimmedLine, "callback_secret") {
41-
parts := strings.SplitN(trimmedLine, "=", 2)
42-
if len(parts) == 2 {
43-
config.CallbackSecret = strings.TrimSpace(parts[1])
44-
}
39+
// 解析键值对
40+
parts := strings.SplitN(trimmedLine, "=", 2)
41+
if len(parts) != 2 {
42+
continue
43+
}
44+
key := strings.TrimSpace(parts[0])
45+
value := strings.TrimSpace(parts[1])
46+
47+
// 根据键更新配置
48+
switch key {
49+
case "port":
50+
config.Port = value
51+
case "scriptpath":
52+
config.ScriptPath = value
53+
case "callback_secret":
54+
config.CallbackSecret = value
4555
}
4656
}
4757

0 commit comments

Comments
 (0)