Looking to get a head start on your next software interview? Pickup a copy of the best book to prepare: Cracking The Coding Interview!
Here’s an example of how to use `string()` to get the primitive value of a string in Go:
str := "Hello, World!"
primitiveStr := string(str)
// primitiveStr now holds the value "Hello, World!"
In the above example, we first declare a string variable `str` with the value “Hello, World!”. We then use the `string()` function to get the primitive value of `str` and assign it to a new variable `primitiveStr`.
It’s important to note that in Go, strings are immutable, meaning that once a string is created, it cannot be modified. Therefore, the `string()` function simply returns a new string with the same value as the original string.