Skip to content

Instantly share code, notes, and snippets.

@MM-coder
Created August 12, 2020 17:02
Show Gist options
  • Save MM-coder/bd5b8380d7e52ae987b16b9b27934134 to your computer and use it in GitHub Desktop.
Save MM-coder/bd5b8380d7e52ae987b16b9b27934134 to your computer and use it in GitHub Desktop.
Most efficent way I could find to iterate through a map in GO
package main
import (
"bytes"
"fmt"
)
func main() {
testMap := map[string]string {"Hello":"World", "World":"Hello"}
var buffer bytes.Buffer
for i:= range testMap {
buffer.WriteString(fmt.Sprintf("Key %v has value %v \n", i, testMap[i]))
}
fmt.Print(buffer.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment