From 837f8457cd046efae6d13a4f5067b77b689726c8 Mon Sep 17 00:00:00 2001 From: Sudhanwa Kaveeshwar <65759652+sid-146@users.noreply.github.com> Date: Thu, 7 Aug 2025 22:06:43 +0530 Subject: [PATCH] Add Go var vs := content --- .../golang/content/var-vs@pJUkMcrUvcxuR_w89-eEq.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/data/roadmaps/golang/content/var-vs@pJUkMcrUvcxuR_w89-eEq.md b/src/data/roadmaps/golang/content/var-vs@pJUkMcrUvcxuR_w89-eEq.md index d338c157b..bf6df7ed2 100644 --- a/src/data/roadmaps/golang/content/var-vs@pJUkMcrUvcxuR_w89-eEq.md +++ b/src/data/roadmaps/golang/content/var-vs@pJUkMcrUvcxuR_w89-eEq.md @@ -1 +1,13 @@ -# var vs := \ No newline at end of file +# var vs := + +Go provides two main ways to declare variables: using `var` and using the short declaration operator `:=`. + +The `var` keyword is used for explicit variable declarations. You can use it to define a variable with or without assigning a value. If no value is provided, Go assigns a default *zero value* based on the variable type. `var` can be used both inside and outside functions. + +The `:=` syntax is a shorthand for declaring and initializing a variable. It infers the type from the value and can only be used **inside functions**. This is a quick and convenient way to create variables without explicitly mentioning their types. + +Visit the following resources to learn more: + +- [@official@Go Tour: Short variable declarations](https://go.dev/tour/basics/10) +- [@official@Go Specification: Short Variable Declarations](https://go.dev/ref/spec#Short_variable_declarations) +