Standard library / encoding/xml

encoding/xml.CharData.Copy()

Copies character-data bytes so later decoder reads or mutations cannot overwrite them. Expected stdout: 'Go\n'.

Formal Syntax & Structure

go syntaxgo
func (c CharData) Copy() CharData

Return Value

CharData

Independent character-data copy.

Working Example

Example Snippetgo
package main
import (  "encoding/xml"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() { v := xml.CharData("Go"); c := v.Copy(); v[0] = 88; fmt.Println(string(c)) }
Go Reference