14 Star 22 Fork 16

openGauss/openGauss-connector-go-pq

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
defaults.go 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
travelliu 提交于 2022-04-15 10:41 . feat: support blob type
// +build !windows
package pq
import (
"os"
"os/user"
"path/filepath"
)
func defaultSettings() map[string]string {
settings := make(map[string]string)
settings[paramHost] = defaultHost()
settings[paramPort] = "5432"
// Default to the OS user name. Purposely ignoring err getting user name from
// OS. The client application will simply have to specify the user in that
// case (which they typically will be doing anyway).
user, err := user.Current()
if err == nil {
settings[paramUser] = user.Username
settings[paramPassFile] = filepath.Join(user.HomeDir, ".pgpass")
settings[paramServiceFile] = filepath.Join(user.HomeDir, ".pg_service.conf")
}
settings[paramTargetSessionAttrs] = "any"
settings[paramMinReadBufferSize] = "8192"
settings[paramCpBufferSize] = "65536"
// settings["client_encoding"] = "GBK"
return settings
}
// defaultHost attempts to mimic libpq's default host. libpq uses the default unix socket location on *nix and localhost
// on Windows. The default socket location is compiled into libpq. Since conn does not have access to that default it
// checks the existence of common locations.
func defaultHost() string {
candidatePaths := []string{
"/var/run/postgresql", // Debian
"/private/tmp", // OSX - homebrew
"/tmp", // standard PostgreSQL
}
for _, path := range candidatePaths {
if _, err := os.Stat(path); err == nil {
return path
}
}
return "localhost"
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opengauss/openGauss-connector-go-pq.git
git@gitee.com:opengauss/openGauss-connector-go-pq.git
opengauss
openGauss-connector-go-pq
openGauss-connector-go-pq
master

搜索帮助