How to convert a string to an array of strings with one element (i.e. that string) in Go effectively.
For example:
var s string
s = "This is a string"
to
["This is a string"]
Obviously, one way would be to make an array of strings and initialize the first element as that string but I am looking for an effective approach.
[1]string{s}is the array containing the strings. Is that syntax all you're asking for?cannot use [1]string literal (type [1]string) as type []string in assignmentmessage []stringso what I want to do ismessage = [s][]string(s).