Standard library / encoding/xml

encoding/xml.Comment.Copy()

Copies the comment byte slice independently. Expected stdout: 'Go\n'.

Formal Syntax & Structure

go syntaxgo
func (c Comment) Copy() Comment

Return Value

Comment

Independent comment copy.

Working Example

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