30 lines
934 B
Go
30 lines
934 B
Go
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
|
|
}
|
|
}
|