Skip to content

Commit

Permalink
fix: generate config parser synatx
Browse files Browse the repository at this point in the history
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
  • Loading branch information
rfyiamcool committed Dec 1, 2023
1 parent c8237c1 commit c916a1d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/go-agent/instrument/plugins/enhance_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (f *ConfigField) GenerateAssignFieldValue(varName string, field, path []str
getFromEnvStr = fmt.Sprintf("if v := tools.GetEnvValue(%q); v != \"\" { result = v };", pluginConfig.EnvKey)
}
parseResStr := ""
parseErrorMessage := "cannot parse the config " + fieldKeyPathStr + ": err.Error()"
parseErrorMessage := fmt.Sprintf(`"cannot parse the config %s: " + err.Error()`, fieldKeyPathStr)
switch f.Type {
case "string":
parseResStr = "return result"
Expand All @@ -240,5 +240,6 @@ func (f *ConfigField) GenerateAssignFieldValue(varName string, field, path []str
}
stmtStr := fmt.Sprintf("%s.%s = func () %s { result := %q; %s%s }()",
varName, fieldPathStr, resultType, pluginConfig.Default, getFromEnvStr, parseResStr)

return tools.GoStringToStats(stmtStr)
}

0 comments on commit c916a1d

Please sign in to comment.