Skip to content

Instantly share code, notes, and snippets.

@jeffotoni
Created October 21, 2019 21:44
Show Gist options
  • Save jeffotoni/160f670193fd5546964c001d61319656 to your computer and use it in GitHub Desktop.
Save jeffotoni/160f670193fd5546964c001d61319656 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"strings"
)
func Substr(value string, leni, lenf int) string {
if len(value) < leni {
return ""
}
lenx := len(value) // max of text
leny := lenf // amount of character
if lenx < lenf { // amount of character
leny = lenx
}
return value[leni:leny]
}
func main() {
strIndex:="/home/netcatc/diretorio1/x3334343x34334343/testef2/guilherme/f2-guilherme-2/folder1/folder2-rename2"
final := len(strIndex)-1
posi := strings.Index(strIndex, "/x3334343x34334343/")
fmt.Println(Substr(strIndex,posi, final))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment