funcmexicanWave(sstring)[]string{if!utf8.ValidString(s){panic("invalid string")}// capacity can be replaced with len(s) if iterating over// the string twice is a bigger problem than allocating too// much memoryss:=make([]string,0,utf8.RuneCountInString(s))fori,r:=ranges{u:=unicode.ToUpper(r)ss=append(ss,s[:i]+string(u)+s[i+utf8.RuneLen(r):])}returnss}
Go:
Play with it here.