看完 聊一个 string 和 []byte 转换问题 顺着去看了 fasthttp 里的代码,本来也想拷一段 s2b/b2s 的代码来用了,可看到注释里有一句

// Note it may break if string and/or slice header will change
// in the future go versions.

又觉得终究还是个有隐患的方法,最后发现自己的 log 库里的转换问题,可以用 io.Writer + fmt.Fprint 来规避。我现在觉得官方库没给出 s2b/b2s 还是有原因的,大部分情况下确实用不上。很多库也都有 WriteString