I user gopkg.in/natefinch/lumberjack.v2 to write log and compress file log. I config log like
func Init() {
file := &lumberjack.Logger{
Filename: "info" + ".log",
MaxSize: 20, // mb
MaxBackups: 5,
Compress: true,
}
id, err := gonanoid.New()
if err != nil {
panic(err)
}
Log = log.New(file, id+" ", log.Ldate|log.Ltime)
}
But id was created once time when I start service. I want to create new id per request. This I usually do with java but got stuck and couldn't find it in Go.