리팩토링
This commit is contained in:
29
internal/path/path.go
Normal file
29
internal/path/path.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package path
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// GetGroupByFolder: group-by 옵션에 따라 백업 경로 생성
|
||||
func GetGroupByFolder(basePath, groupBy string, t time.Time) string {
|
||||
switch groupBy {
|
||||
case "year":
|
||||
return fmt.Sprintf("%s/%d", basePath, t.Year())
|
||||
case "mon":
|
||||
return fmt.Sprintf("%s/%d%02d", basePath, t.Year(), t.Month())
|
||||
case "day":
|
||||
return fmt.Sprintf("%s/%d%02d%02d", basePath, t.Year(), t.Month(), t.Day())
|
||||
case "hour":
|
||||
return fmt.Sprintf("%s/%d%02d%02d_%02d", basePath, t.Year(), t.Month(), t.Day(), t.Hour())
|
||||
case "min":
|
||||
return fmt.Sprintf("%s/%d%02d%02d_%02d%02d", basePath, t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute())
|
||||
case "sec":
|
||||
return fmt.Sprintf("%s/%d%02d%02d_%02d%02d%02d", basePath, t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second())
|
||||
case "":
|
||||
return basePath
|
||||
default:
|
||||
fmt.Printf("지원하지 않는 group-by 옵션입니다: %s\n", groupBy)
|
||||
return basePath
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user