Is there an elegant way in Go to do multiple assignments from arrays like in Python? Here is a Python example of what I'm trying to do (split a string and then assign the resulting array into two variables).
python:
>>> a, b = "foo;bar".split(";")
My current solution is:
x := strings.Split("foo;bar", ";")
a, b := x[0], x[1]
I'm can see this getting messy in some constructs. The practical example I'm currently facing is a bookmark file parsing and assigning to a map:
bookmark := make(map[string]string)
x := strings.Split("foo\thttps://bar", "\t")
name, link := x[0], x[1]
bookmark[name] = link
Now I have a useless variable x
sitting around. I'd like to do something like:
bookmark := make(map[string]string)
name, line := strings.Split("foo\thttps://bar", "\t")
bookmark[name] = link
but that's invalid.