Strings are slices in Google Go, so there is really no need for a Golang substr function. For example if you would want to get the first 10 characters of a string:
dt := "2015-01-01 15:45:12"
d := dt[0:10]
The resulting value in d will be: "2015-01-01".
This helped. Thanks
Except if you're using characters which take up more than one byte: https://play.golang.org/p/W5WLsge6pG9
Correct, if you use multi byte chars, you have to use runes:
for i, ch := range "Japan 日本" {
fmt.Printf("%d:%q ", i, ch)
}
// Output: 0:'J' 1:'a' 2:'p' 3:'a' 4:'n' 5:' ' 6:'日' 9:'本'