build source
This commit is contained in:
commit
ee1fec43ed
4171 changed files with 1351288 additions and 0 deletions
37
vendor/github.com/fergusstrange/embedded-postgres/cache_locator.go
generated
vendored
Normal file
37
vendor/github.com/fergusstrange/embedded-postgres/cache_locator.go
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package embeddedpostgres
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// CacheLocator retrieves the location of the Postgres binary cache returning it to location.
|
||||
// The result of whether this cache is present will be returned to exists.
|
||||
type CacheLocator func() (location string, exists bool)
|
||||
|
||||
func defaultCacheLocator(cacheDirectory string, versionStrategy VersionStrategy) CacheLocator {
|
||||
return func() (string, bool) {
|
||||
if cacheDirectory == "" {
|
||||
cacheDirectory = ".embedded-postgres-go"
|
||||
if userHome, err := os.UserHomeDir(); err == nil {
|
||||
cacheDirectory = filepath.Join(userHome, ".embedded-postgres-go")
|
||||
}
|
||||
}
|
||||
|
||||
operatingSystem, architecture, version := versionStrategy()
|
||||
cacheLocation := filepath.Join(cacheDirectory,
|
||||
fmt.Sprintf("embedded-postgres-binaries-%s-%s-%s.txz",
|
||||
operatingSystem,
|
||||
architecture,
|
||||
version))
|
||||
|
||||
info, err := os.Stat(cacheLocation)
|
||||
|
||||
if err != nil {
|
||||
return cacheLocation, os.IsExist(err) && !info.IsDir()
|
||||
}
|
||||
|
||||
return cacheLocation, !info.IsDir()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue