Standard library / bytes

bytes.Clone()

Returns a copy of the input byte slice; nil input returns nil. The result can be retained independently of later input mutation. Expected stdout: 'hello\n'.

Formal Syntax & Structure

go syntaxgo
func Clone(b []byte) []byte

Parameters & Attributes

NameTypeDescription
b[]byteByte sequence or second comparison input.

Return Value

[]byte

Returns a copy of the input byte slice; nil input returns nil. The result can be retained independently of later input mutation.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  fmt.Println(string(bytes.Clone([]byte("hello"))))}
Go Reference