package main import "fmt" func main() { s := "hello" // a string can't be mutated; convert to []byte to change it b := []byte(s) b[0] = 'H' // convert back to a fresh string fmt.Println(string(b)) }
edit text via a byte slice