mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Minor formatting
This commit is contained in:
parent
d8bd169cb7
commit
d09b71262a
2 changed files with 24 additions and 20 deletions
|
|
@ -11,10 +11,10 @@ import (
|
|||
)
|
||||
|
||||
func PathExists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil { return true, nil }
|
||||
if os.IsNotExist(err) { return false, nil }
|
||||
return false, err
|
||||
_, err := os.Stat(path)
|
||||
if err == nil { return true, nil }
|
||||
if os.IsNotExist(err) { return false, nil }
|
||||
return false, err
|
||||
}
|
||||
|
||||
func MakeRequest(url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error) {
|
||||
|
|
@ -37,20 +37,20 @@ func MakeRequest(url string, httpMethod string, body []byte, headers map[string]
|
|||
}
|
||||
|
||||
func MakeOutputDirectory(path string) (string, error) {
|
||||
// get the current data + time using Go's stupid formatting
|
||||
t := time.Now()
|
||||
dirname := t.Format("2006-01-01 15:04:05")
|
||||
final := path + "/" + dirname
|
||||
// get the current data + time using Go's stupid formatting
|
||||
t := time.Now()
|
||||
dirname := t.Format("2006-01-01 15:04:05")
|
||||
final := path + "/" + dirname
|
||||
|
||||
// check if path is valid and directory
|
||||
pathExists, err := PathExists(final);
|
||||
if err != nil {
|
||||
return final, fmt.Errorf("could not check for existing path: %v", err)
|
||||
}
|
||||
pathExists, err := PathExists(final);
|
||||
if err != nil {
|
||||
return final, fmt.Errorf("could not check for existing path: %v", err)
|
||||
}
|
||||
if pathExists {
|
||||
// make sure it is directory with 0o644 permissions
|
||||
return final, fmt.Errorf("found existing path: %v", final)
|
||||
}
|
||||
// make sure it is directory with 0o644 permissions
|
||||
return final, fmt.Errorf("found existing path: %v", final)
|
||||
}
|
||||
|
||||
// create directory with data + time
|
||||
err = os.MkdirAll(final, 0766)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue