This question already has an answer here:
I have a trouble with my current golang's project.
I have another package in go that result an array with pretedermined key, example :
package updaters
var CustomSql map[string]string
func InitSqlUpdater() {
CustomSql = map[string]string{
"ShouldBeFirst": "Text Should Be First",
"ShouldBeSecond": "Text Should Be Second",
"ShouldBeThird": "Text Should Be Third",
"ShouldBeFourth": "Text Should Be Fourth"
}
}
And send it to main.go, to iterate each index and value, but the results is random (In my situation, I need that in sequence).
Real Case : https://play.golang.org/p/ONXEiAj-Q4v
I google why the golangs iterate in random way, and the example is using sort, but my array keys is predetermined, and sort is only for asc desc alphabet and number.
So, How can I achieve the way that arrays is not being randomize in iterate?
ShouldBeFirst = Text Should Be First
ShouldBeSecond = Text Should Be Second
ShouldBeThird = Text Should Be Third
ShouldBeFourth = Text Should Be Fourth
Anyhelp will appreciate, thanks.
</div>