MCPcopy Index your code
hub / github.com/gogf/gf / configNodeToSource

Function configNodeToSource

contrib/drivers/pgsql/pgsql_open.go:37–69  ·  view source on GitHub ↗
(config *gdb.ConfigNode)

Source from the content-addressed store, hash-verified

35}
36
37func configNodeToSource(config *gdb.ConfigNode) (string, error) {
38 var source string
39 source = fmt.Sprintf(
40 "user=%s password='%s' host=%s sslmode=disable",
41 config.User, config.Pass, config.Host,
42 )
43 if config.Port != "" {
44 source = fmt.Sprintf("%s port=%s", source, config.Port)
45 }
46 if config.Name != "" {
47 source = fmt.Sprintf("%s dbname=%s", source, config.Name)
48 }
49 if config.Namespace != "" {
50 source = fmt.Sprintf("%s search_path=%s", source, config.Namespace)
51 }
52 if config.Timezone != "" {
53 source = fmt.Sprintf("%s timezone=%s", source, config.Timezone)
54 }
55 if config.Extra != "" {
56 extraMap, err := gstr.Parse(config.Extra)
57 if err != nil {
58 return "", gerror.WrapCodef(
59 gcode.CodeInvalidParameter,
60 err,
61 `invalid extra configuration: %s`, config.Extra,
62 )
63 }
64 for k, v := range extraMap {
65 source += fmt.Sprintf(` %s=%s`, k, v)
66 }
67 }
68 return source, nil
69}

Callers 1

OpenMethod · 0.70

Calls 2

ParseFunction · 0.92
WrapCodefFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…