github.com/gogf/gf@v1.16.9/container/garray/garray_z_example_str_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/gogf/gf.
     6  
     7  package garray_test
     8  
     9  import (
    10  	"fmt"
    11  	"github.com/gogf/gf/container/garray"
    12  	"github.com/gogf/gf/frame/g"
    13  )
    14  
    15  func ExampleStrArray_Walk() {
    16  	var array garray.StrArray
    17  	tables := g.SliceStr{"user", "user_detail"}
    18  	prefix := "gf_"
    19  	array.Append(tables...)
    20  	// Add prefix for given table names.
    21  	array.Walk(func(value string) string {
    22  		return prefix + value
    23  	})
    24  	fmt.Println(array.Slice())
    25  
    26  	// Output:
    27  	// [gf_user gf_user_detail]
    28  }