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.
Here is the corrected version of your blog post with improved grammar and flow, while maintaining your personal style:
In my previous post, we learned about pointers and how it is used.
Let's learn about struct data type.
Struct Data Type
Struct is a user-defined data type in Go that allows you to group fields of different types together.
Structs can be initialized in multiple ways.
- Using field names
- Using field positions
Here is an example of a struct initialized using field names:
Initialization using named fields
we have use type keyword to define a struct.
package main
import "fmt"
type developer struct {
Name string
Age int
}
func main() {
person := developer{Name: "John", Age: 30}
fmt.Println(person)
}
For above example we have defined a struct developer with two fields Name and Age.
For initializing the struct we have used field names.
Where under developer struct we have defined two fields Name and Age with John and 30 values.
Let's see the output.
Output:
gk@jarvis:~/exp/code/rd/go-exmaple$ go run main.go
{John 30}
As we can see the output is {John 30}.
This is how fmt.Println works with struct data type.
Accessing Fields
We can access the fields of a struct using the dot operator.
let's print each data one by one.
package main
import "fmt"
type developer struct {
Name string
Age int
}
func main() {
person := developer{Name: "John", Age: 30}
fmt.Println(person.Name)
fmt.Println(person.Age)
}
Output:
gk@jarvis:~/exp/code/rd/go-exmaple$ go run main.go
John
30
We could able to access the fields of a struct using the dot operator.
Now let's see how we can initialize the struct using field positions.
Initializing Struct with field positions
package main
import "fmt"
type developer struct {
Name string
Age int
}
func main() {
person := developer{"John", 30}
fmt.Println(person)
}
Output:
gk@jarvis:~/exp/code/rd/go-exmaple$ go run main.go
{John 30}
We got same output as previous example.
Now let's see how we can use pointer to modify the struct.
Pointer to Struct
Define pointer to struct is same as define pointer to any other data type.
package main
import "fmt"
type developer struct {
Name string
Age int
}
func main() {
d := developer{Name: "John", Age: 30}
p := &d
fmt.Println(d)
p.Name = "Jane"
p.Age = 1e9
fmt.Println(d)
}
Output:
gk@jarvis:~/exp/code/rd/go-exmaple$ go run main.go
{John 30}
{Jane 1000000000}
As we can see the output is {John 30} and {Jane 1000000000}.
Conclusion
In this we learned about struct data type and used pointer to modify the struct.
π 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)