1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package utils
- import (
- "fmt"
- "strings"
- )
- // 定义一个自定义类型
- type MyFmt struct {
- str string
- }
- // 实现 Stringer 接口
- func (m MyFmt) String() string {
- return fmt.Sprintf("---------------------%v----------------------", m.str)
- }
- func (m MyFmt) SetStr(str string) string {
- m.str = str
- return m.str
- }
- func SplitFileLocal(sql string) []string {
- fmt.Println("SplitFileLocal.sql = ", sql)
- var fileLocal []string
- var f func(sql string)
- f = func(sql string) {
- // 找到第一个<的位置
- semicolonIndex := strings.Index(sql, "<")
- if semicolonIndex != -1 {
- lastIndex := strings.LastIndex(sql, "<")
- fileLocal = append(fileLocal, sql[lastIndex+2:])
- fmt.Println(" rear[lastIndex+2:]", sql[lastIndex+2:])
- sql = sql[:lastIndex]
- fmt.Println(" sql[:lastIndex]", sql[:lastIndex])
- f(sql)
- } else {
- fmt.Println("未找到<。")
- }
- }
- f(sql)
- for i, j := 0, len(fileLocal)-1; i < j; i, j = i+1, j-1 {
- fileLocal[i], fileLocal[j] = fileLocal[j], fileLocal[i]
- }
- fmt.Printf("\nfileLocal排序后:%v\n", fileLocal)
- return fileLocal
- }
|