Standard library / strings

strings.Clone()

Returns a copy of a nonempty string with independent backing storage; empty string requires no allocation. Expected stdout: 'hello\n'.

Formal Syntax & Structure

go syntaxgo
func Clone(s string) string

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.

Return Value

string

Returns a copy of a nonempty string with independent backing storage; empty string requires no allocation.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  fmt.Println(string(strings.Clone("hello")))}
Go Reference