In Go, an empty string is represented by assigning an empty value to a variable of type string.
In this example,
emptyString
and initialize it with an empty string literal ""
.emptyString
now holds an empty string.package main
import "fmt"
func main() {
var emptyString string
fmt.Printf("Empty string created: '%s'", emptyString)
}
Empty string created: ''
In this tutorial, we learned How to Create an Empty String in Go language with well detailed examples.