go语言byte类型报错cannot use "c" ,type string as type byte in assignment

  练习Go修改字符串的时候遇到这个问题:cannot use "c" (type string) as type byte in assignment,代码如下:

package main

import "fmt"

func main() {
        s := "hello"
        c := []byte(s)  // 将字符串转为[]byte类型
        c[0] = 'c'      // byte用''单引号包括字符 不然报错cannot use "c" (type string) as type byte in assignment
        s2 := string(c) // 再转为string类型
        fmt.Printf("%s\n", s2)
}

  byte类型是使用单引号包括字符的,当时使用的双引号,所以报了这个错误,在此记录一下。