I want to create a pair such as pair(string, int)
. I know that in go there is no pair type, and I also know that slices can only hold the same data type.
How may I do this?
Go doesn't have tuples like some other languages. You can create a struct type with a string and an int field:
type myStruct struct {
str string
num int
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With