PostgreSQL 의존성 및 내부 유틸리티 추가:
Some checks failed
Build Push and Restart Compose / deploy (push) Failing after 1m47s
Some checks failed
Build Push and Restart Compose / deploy (push) Failing after 1m47s
- `github.com/lib/pq` PostgreSQL 드라이버 vendor 디렉토리에 추가. - PostgreSQL 관련 내부 패키지(`pqsql`, `proto`, `pqtime`, `pgpass`, `pgservice`, `pqutil`) 구현: - SQL 어휘 처리, 프로토콜 상수 및 구조 정의, 시간 파서/포맷터(`Parse`, `Format`). - `.pgpass` 파일 및 `pg_service.conf` 관리 기능 추가. - 파일/사용자 권한 검증 및 플랫폼별 사용자 정보 조회 기능 포함. - 데이터베이스 초기화 로직 추가 (`services/db.go`): - PostgreSQL 연결 설정 및 초기 스키마 생성. - 자동매매 관련 DB 레포지토리(`services/autotrade_repo.go`) 구현: - 자동매매 규칙 및 포지션 관리 로직 추가 (`dbInsertRule`, `dbLoadRules` 등).
This commit is contained in:
91
vendor/github.com/lib/pq/internal/pqutil/path.go
generated
vendored
Normal file
91
vendor/github.com/lib/pq/internal/pqutil/path.go
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
package pqutil
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Home gets the PostgreSQL configuration dir in the user's home directory:
|
||||
// %APPDATA%/postgresql on Windows, and $HOME/.postgresql/postgresql.crt
|
||||
// everywhere else.
|
||||
//
|
||||
// Returns an empy string if no home directory was found.
|
||||
//
|
||||
// Matches pqGetHomeDirectory() from PostgreSQL.
|
||||
// https://github.com/postgres/postgres/blob/2b117bb/src/interfaces/libpq/fe-connect.c#L8214
|
||||
func Home(subdir bool) string {
|
||||
if runtime.GOOS == "windows" {
|
||||
// pq uses SHGetFolderPath(), which is deprecated but x/sys/windows has
|
||||
// KnownFolderPath(). We don't really want to pull that in though, so
|
||||
// use APPDATA env. This is also what PostgreSQL uses in some other
|
||||
// codepaths (get_home_path() for example).
|
||||
ad := os.Getenv("APPDATA")
|
||||
if ad == "" {
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(ad, "postgresql")
|
||||
}
|
||||
|
||||
home, _ := os.UserHomeDir()
|
||||
if home == "" {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
home = u.HomeDir
|
||||
}
|
||||
// libpq reads some files from ~/ and some from ~/.postgresql – on Windows
|
||||
// it always uses %APPDATA%/postgresql.
|
||||
if subdir {
|
||||
home = filepath.Join(home, ".postgresql")
|
||||
}
|
||||
return home
|
||||
}
|
||||
|
||||
// ErrNotExists reports if err is a "path doesn't exist" type error.
|
||||
//
|
||||
// fs.ErrNotExist is not enough, as "/dev/null/somefile" will return ENOTDIR
|
||||
// instead of ENOENT.
|
||||
func ErrNotExists(err error) bool {
|
||||
perr := new(os.PathError)
|
||||
if errors.As(err, &perr) && (perr.Err == syscall.ENOENT || perr.Err == syscall.ENOTDIR) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var WarnFD io.Writer = os.Stderr
|
||||
|
||||
// Pgpass gets the filepath to the pgpass file to use, returning "" if a pgpass
|
||||
// file shouldn't be used.
|
||||
func Pgpass(passfile string) string {
|
||||
// Get passfile from the options.
|
||||
if passfile == "" {
|
||||
home := Home(false)
|
||||
if home == "" {
|
||||
return ""
|
||||
}
|
||||
passfile = filepath.Join(home, ".pgpass")
|
||||
}
|
||||
|
||||
// On Win32, the directory is protected, so we don't have to check the file.
|
||||
if runtime.GOOS != "windows" {
|
||||
fi, err := os.Stat(passfile)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if fi.Mode().Perm()&(0x77) != 0 {
|
||||
fmt.Fprintf(WarnFD,
|
||||
"WARNING: password file %q has group or world access; permissions should be u=rw (0600) or less\n",
|
||||
passfile)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return passfile
|
||||
}
|
||||
Reference in New Issue
Block a user