mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 13:18:01 +08:00
44 lines
884 B
Go
44 lines
884 B
Go
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
//
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
// If a copy of the MIT was not distributed with gm file,
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
package gset_test
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gogf/gf/container/gset"
|
|
"github.com/gogf/gf/frame/g"
|
|
)
|
|
|
|
func ExampleStrSet_Contains() {
|
|
var set gset.StrSet
|
|
set.Add("a")
|
|
fmt.Println(set.Contains("a"))
|
|
fmt.Println(set.Contains("A"))
|
|
fmt.Println(set.ContainsI("A"))
|
|
|
|
// Output:
|
|
// true
|
|
// false
|
|
// true
|
|
}
|
|
|
|
func ExampleStrSet_Walk() {
|
|
var (
|
|
set gset.StrSet
|
|
names = g.SliceStr{"user", "user_detail"}
|
|
prefix = "gf_"
|
|
)
|
|
set.Add(names...)
|
|
// Add prefix for given table names.
|
|
set.Walk(func(item string) string {
|
|
return prefix + item
|
|
})
|
|
fmt.Println(set.Slice())
|
|
|
|
// May Output:
|
|
// [gf_user gf_user_detail]
|
|
}
|