Variable scope refers to the block or region of code in which a variable can be accessed. Go uses lexical scoping (also known as static scoping) based on blocks.

A block is a sequence of declarations and statements enclosed within matching curly braces {}.

Let's consider the following Go code:

package main

import "fmt"