Skip to content

Instantly share code, notes, and snippets.

@psahni
Last active November 21, 2023 12:28
Show Gist options
  • Save psahni/02ce47cb3340ea1438efc6c49b6d4da6 to your computer and use it in GitHub Desktop.
Save psahni/02ce47cb3340ea1438efc6c49b6d4da6 to your computer and use it in GitHub Desktop.
code_snippets_go.go
type Employee string

const (
	Manager      Employee = "manager"
	Developer    Employee = "Developer"
	Tester       Employee = "Tester"
)
@psahni
Copy link
Author

psahni commented Nov 20, 2023

Loop over map

 
func main() {
	// Allocate memory for the map
	var myMap = make(map[int]string)
	myMap[0] = "test"
	myMap[2] = "sample"
	myMap[1] = "Golang is Fun!"
	
	// Iterate over all keys
	for key, val := range myMap {
		fmt.Printf("Key: %d, Value: %s\n", key, val)
	}
}

https://golangdocs.com/golang-iterate-over-a-map

@psahni
Copy link
Author

psahni commented Nov 20, 2023

Create Date
theTime := time.Date(2021, 8, 15, 14, 30, 45, 100, time.Local)

@psahni
Copy link
Author

psahni commented Nov 21, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment