mirror of
https://github.com/astaxie/beego.git
synced 2025-06-11 07:00:40 +00:00
move utils to utils libs & func move to templatefunc
This commit is contained in:
10
utils/slice.go
Normal file
10
utils/slice.go
Normal file
@ -0,0 +1,10 @@
|
||||
package utils
|
||||
|
||||
func InSlice(v string, sl []string) bool {
|
||||
for _, vv := range sl {
|
||||
if vv == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
15
utils/slice_test.go
Normal file
15
utils/slice_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInSlice(t *testing.T) {
|
||||
sl := []string{"A", "b"}
|
||||
if !InSlice("A", sl) {
|
||||
t.Error("should be true")
|
||||
}
|
||||
if InSlice("B", sl) {
|
||||
t.Error("should be false")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user