Skip to content

Chapter 02: Introduction & Setup ​

A master craftsman needs sharp tools. Let's set up your environment.

1. Install Go (The Compiler) ​

Go is a compiled language. You need the "Compiler" to turn your text code into a binary program that the computer understands.

  • Download: go.dev/dl
  • Verify: Open your terminal (Command Prompt) and type:
    bash
    go version
    You should see something like go version go1.27.1 ... (the book’s verification baseline; the platform suffix varies).

2. The Code Editor (VS Code) ​

We recommend Visual Studio Code (VS Code). It is free and powerful.

  1. Download VS Code.
  2. Optional editor integration: Install the Go Extension by the Go Team at Google.
    • Click the "Extensions" box on the left sidebar.
    • Search for "Go".
    • Install the one with the blue Gopher icon.

3. The Commands (Your Toolbar) ​

You will use three main commands in your terminal:

A. go mod init [name] ​

"Initialize Project" This creates a go.mod file. Think of it as the "Passport" for your project. It tells Go clearly who you are.

bash
go mod init github.com/myname/myproject

B. go run . ​

"Test Run" This compiles your code in a temporary folder and runs it immediately. The dot includes all ordinary Go files in the current package. Passing only main.go omits other source files.

C. go build ​

"Manufacture" This creates a permanent binary file (executable). You can send this file to a friend, and they can run it without having Go installed, provided the operating system, architecture, and runtime dependencies match.


Next: Now that the shop is open, let's learn how to read the blueprints.

🎓 Knowledge Check: What command do we use to initialize a new Go module?

Answer: go mod init <module-name>. This creates the go.mod file, which is like the ID card for your project.

4 The Visual Signal (The Workbench) ​

Concept: Integrated Development Environment (IDE). Signal: A carpenter's workbench where all tools are within reach.

Released under the MIT License.