Hello, I'm Ganesh Kumar. I'm working on git-lrc: a Git hook for Checking AI generated code.AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.
In my previous post, I explained how to loop over a slice using normal index based loop and range function.
In this post, I will explain what are maps and how to create them.
Why maps are used?
Go offers a very simple implementation of hash maps where you can call it has dictionary or hash table.
The typical structure of a map is:
map[keyType]valueType
Where keyType is the type of the key and valueType is the type of the value.
keyType mostly be a string, but we can also use other data types as a key.
keyType must be a type that can be compared using the == operator.
Whenever we want to access a value quickly, or modify a value, we use the maps.
How to create maps
let's see how to create a map using make function and litral.
For the example let's consider a map of pc name and price in dollars.
- Create a map using make function
Assign the map to a variable and then assign the values to it.
package main
import "fmt"
func main() {
mymap := make(map[string]int)
mymap["hp"] = 1000
mymap["dell"] = 800
mymap["lenovo"] = 600
fmt.Println(mymap)
fmt.Println(mymap["hp"])
}
Output:
map[dell:800 hp:1000 lenovo:600]
1000
Here we created a map using make function and assigned the values to it.
- create a map using litral
Assign the map to a variable and then assign the values to it.
package main
import "fmt"
func main() {
mymap := map[string]int{}
mymap["hp"] = 1000
mymap["dell"] = 800
mymap["lenovo"] = 600
fmt.Println(mymap)
fmt.Println(mymap["hp"])
}
Output:
map[dell:800 hp:1000 lenovo:600]
1000
We can see that the map is created and the values are stored in it.
Conclusion
We understood what are maps and how to create them.
π Check out: git-lrc
Any feedback or contributors are welcome! Itβs online, open-source, and ready for anyone to use.
β Star it on GitHub:
HexmosTech
/
git-lrc
Free, Unlimited AI Code Reviews That Run on Commit
AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.
git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.
See It In Action
See git-lrc catch serious security issues such as leaked credentials, expensive cloud operations, and sensitive material in log statements
git-lrc-intro-60s.mp4
Why
- π€ AI agents silently break things. Code removed. Logic changed. Edge cases gone. You won't notice until production.
- π Catch it before it ships. AI-powered inline comments show you exactly what changed and what looks wrong.
- π Build a habit, ship better code. Regular review β fewer bugs β more robust code β better results in your team.
- π Why git? Git is universal. Every editor, every IDE, every AIβ¦
https://github.com/golang/go/blob/master/src/runtime/slice.go

Top comments (0)