How to replace the Nth char in a string in Go

1 Answer

0 votes
package main

import "fmt"

func main() {
    var str = "go lang"
    
    N := 3
    
    str = str[:N] + "_" + str[N + 1:]        

    fmt.Printf(str)
}




/*
run:

go _ang

*/

 



answered Jun 13, 2022 by avibootz

Related questions

...