-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (46 loc) · 1.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"gopkg.in/gographics/imagick.v3/imagick"
"imageconverter/constant"
"imageconverter/controller"
"os"
)
func main() {
loggerSetup()
fileInfo, err := os.Lstat("./")
if err != nil {
zap.S().Fatalf("failed to get file info: %v", err)
}
fileMode := fileInfo.Mode()
unixPerms := fileMode & os.ModePerm
err = os.MkdirAll(constant.UPLOAD_FILE_PATH, unixPerms)
if err != nil {
zap.S().Fatalf("failed to create directory: %v", err)
}
err = os.MkdirAll(constant.CONVERTED_FILE_PATH, unixPerms)
if err != nil {
zap.S().Fatalf("failed to create directory: %v", err)
}
imagick.Initialize()
defer imagick.Terminate()
mw := imagick.NewMagickWand()
defer mw.Destroy()
formats := mw.QueryFormats("*")
fmt.Printf("supported image format: %v", formats)
r := controller.Router()
r.Run()
}
func loggerSetup() {
config := zap.NewProductionConfig()
encoderConfig := zap.NewProductionEncoderConfig()
encoderConfig.TimeKey = "timestamp"
encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
config.EncoderConfig = encoderConfig
config.Level = zap.NewAtomicLevelAt(zapcore.DebugLevel)
logger, _ := config.Build(zap.AddCallerSkip(1))
defer logger.Sync()
zap.ReplaceGlobals(logger)
}