Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 5bdfe7d

Browse files
committed
shared: use string literals in the config file
This removes the need to double up backslashes for paths
1 parent c659428 commit 5bdfe7d

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

cmd/shared.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,19 @@ func generateConfig(cfgFile string) (err error) {
213213
}
214214
defer f.Close()
215215
lineEnd := "\n"
216-
warnMsg := ""
217216
if runtime.GOOS == "windows" {
218217
lineEnd = "\r\n"
219-
warnMsg = " # On Windows, directory slashes need to be doubled up otherwise parsing fails."
220218
}
221-
safeChainFile := strings.ReplaceAll(chainFile, `\`, `\\`)
222219
certPath := fmt.Sprintf("%c%s", os.PathSeparator, filepath.Join("path", "to", "your", "certificate", "here"))
223-
safeCertPath := strings.ReplaceAll(certPath, `\`, `\\`)
224220
_, err = fmt.Fprint(f, `[certs]`+lineEnd)
225-
_, err = fmt.Fprint(f, fmt.Sprintf(`cachain = "%s"%s`, safeChainFile, lineEnd))
226-
_, err = fmt.Fprint(f, fmt.Sprintf(`cert = "%s"%s%s`, safeCertPath, warnMsg, lineEnd))
221+
_, err = fmt.Fprint(f, fmt.Sprintf(`cachain = '%s'%s`, chainFile, lineEnd))
222+
_, err = fmt.Fprint(f, fmt.Sprintf(`cert = '%s'%s`, certPath, lineEnd))
227223
_, err = fmt.Fprint(f, lineEnd)
228224
_, err = fmt.Fprint(f, `[general]`+lineEnd)
229-
_, err = fmt.Fprint(f, `cloud = "https://dbhub.io:5550"`+lineEnd)
225+
_, err = fmt.Fprint(f, `cloud = 'https://dbhub.io:5550'`+lineEnd)
230226
_, err = fmt.Fprint(f, lineEnd)
231227
_, err = fmt.Fprint(f, `[user]`+lineEnd)
232-
_, err = fmt.Fprint(f, `name = "Your Name"`+lineEnd)
228+
_, err = fmt.Fprint(f, `name = 'Your Name'`+lineEnd)
233229
return
234230
}
235231

0 commit comments

Comments
 (0)