---
title: "Comment by Soham Karandikar on \"Understanding the Go Compiler: From Source Code to Execution\" | Hashnode"
description: "Great post! I wonder how references in go compare to those in Rust. How does the go compiler check for safety of passing/accessing references?"
url: "https://hashnode.com/posts/understanding-the-go-compiler/67449cec1d5b48f034c6315c/comment/67449f28885e71030e946224"
---

[Discussion](https://hashnode.com/posts/understanding-the-go-compiler/67449cec1d5b48f034c6315c)

Comment [Understanding the Go Compiler: From Source Code to Execution](https://hashnode.com/posts/understanding-the-go-compiler/67449cec1d5b48f034c6315c)

[Soham Karandikar](https://hashnode.com/@skadewdl3)

[Nov 25, 2024](https://hashnode.com/posts/understanding-the-go-compiler/67449cec1d5b48f034c6315c/comment/67449f28885e71030e946224)

Great post! I wonder how references in go compare to those in Rust. How does the go compiler check for safety of passing/accessing references?

[Arya M. Pathak](https://hashnode.com/@arya2004)

[Nov 25, 2024](https://hashnode.com/posts/understanding-the-go-compiler/67449cec1d5b48f034c6315c/comment/67449f28885e71030e946224#reply-6744bf9b171091766d68f3e4)

Great question about references in Go versus Rust! Here's a simple explanation:

In Rust, the compiler uses a system called "borrow checking" to ensure reference safety. It strictly enforces rules about ownership, borrowing, and lifetimes. This ensures that references are safe, avoiding common issues like dangling pointers or data races.

Go, on the other hand, has a simpler memory model. While it doesn’t have explicit ownership rules like Rust, Go's garbage collector takes care of memory management. The compiler ensures safe access to references by checking for scope violations and other basic issues during compile time. Since Go is designed for simplicity and concurrency, it relies on runtime mechanisms (like garbage collection) to manage memory safety rather than strict compile-time checks like Rust.

Let me know if you'd like a deeper dive into this comparison!
