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 create slices and how it works internally.
Using Structs with Slices
We can store any data type in a slice.
For example, we can store a struct in a slice.
package main
import "fmt"
type Person struct {
Name string
Age int
}
func main() {
people := []Person{
{Name: "John", Age: 30},
{Name: "Jane", Age: 25},
}
fmt.Println(people)
}
The output of the code will be having data with {} output inside square brackets[].
Output:
[{John 30} {Jane 25}]
Re-Slices The Existing Slice
When we do slicing from new slice with different start point then it will create new slice with different pointer.
if we change the pointer then data the previous pointer will be losted.
To identify how it works let's see the below example.
package main
import "fmt"
func main() {
s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
printSlice(s)
s = s[1:5]
printSlice(s)
s = s[2:]
printSlice(s)
s = s[:1]
printSlice(s)
}
func printSlice(s []int) {
fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
}
Here is the visual representation.
Output:
This is the actual output of the code.
gk@jarvis:~/exp/code/rd/go-exmaple$ go run main.go
len=10 cap=10 [1 2 3 4 5 6 7 8 9 10]
len=4 cap=9 [2 3 4 5]
len=2 cap=7 [4 5]
len=1 cap=7 [4]
Conclusion
In this we learned about storing data in slices and did some slice modifications to understand how it works.
π 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β¦


Top comments (0)