1
0
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:
astaxie
2013-12-12 22:25:08 +08:00
parent d603a6714d
commit 19119e99f7
7 changed files with 555 additions and 591 deletions

10
utils/slice.go Normal file
View 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
View 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")
}
}