package generate import ( "fmt" "git.aiterp.net/rpdata/api/models" "time" ) // LogID generates a log ID in the format is 2019-05-22_191341547_RedrockAgency func LogID(log models.Log) string { if len(log.ChannelName) < 1 { panic("ChannelName is not valid (validate input before calling this function!)") } datetime := log.Date.UTC().Format("2006-01-02_150405") milliseconds := (log.Date.UnixNano() % int64(time.Second)) / 1000000 channelName := log.ChannelName[1:] return fmt.Sprintf("%s%03d_%s", datetime, milliseconds, channelName) }