26 lines
409 B
Go
26 lines
409 B
Go
package core
|
|
|
|
import "time"
|
|
|
|
// Contains checks if slice a contains string str
|
|
func Contains(str string, a []string) (int, bool) {
|
|
for i, s := range a {
|
|
if s == str {
|
|
return i, true
|
|
}
|
|
}
|
|
return -1, false
|
|
}
|
|
|
|
const (
|
|
timeFmt = "2006-01-02 15:04:05"
|
|
fileFmt = "20060102_150405"
|
|
)
|
|
|
|
func Now() string {
|
|
return time.Now().Format(timeFmt)
|
|
}
|
|
|
|
func FileName() string {
|
|
return time.Now().Format(fileFmt)
|
|
}
|