← Back to Go Course | Chapter 1: Setup & Basics | Lesson 2 of 7

Go इंस्टॉल करना

Go install करने का मतलब है आधिकारिक toolkit को अपने computer पर download करना ताकि यह जान सके कि आपके code को एक चलने वाले program में कैसे बदला जाए।

Downloading the Go Toolchain

Go हर platform के लिए एक single installer के रूप में ship होता है जिसमें compiler, standard library, और 'go build' व 'go fmt' जैसे tools शामिल हैं। macOS और Windows पर आप एक graphical installer चलाते हैं; Linux पर आप आमतौर पर एक tarball को /usr/local/go में extract करते हैं या अपने distribution के package manager का उपयोग करते हैं।

चूंकि यह आपके अपने terminal में किया जाने वाला एक installation step है, यह इस page के live-code box के अंदर चलने वाली कोई चीज़ नहीं है।

Note: हमेशा Go को आधिकारिक https://go.dev/dl page या अपने OS package manager (जैसे 'brew install go', 'apt install golang-go') से लें।

उदाहरण: Downloading the Go Toolchain

bash
# Linux
wget https://go.dev/dl/go1.22.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.22.0.linux-amd64.tar.gz

# Windows
# Download MSI installer from https://go.dev/dl/
# Run the installer — it sets PATH automatically

⚠️ Run this in your own terminal or Node.js environment.

Adding Go to your PATH

Go binaries एक bin folder में रहते हैं जिसके बारे में आपके shell को जानना चाहिए ताकि किसी भी directory से go टाइप करना काम करे।

Linux/macOS पर इसका आमतौर पर मतलब है Go install location को PATH environment variable पर export करना; Windows पर installer यह अपने आप करता है। इस step के बिना, Go installed होने के बावजूद terminal 'go: command not found' report करता है।

Note: इस line को ~/.bashrc, ~/.zshrc, या अपनी shell की profile file में जोड़ें ताकि यह terminal sessions में बना रहे।

उदाहरण: Adding Go to your PATH

bash
# Linux/macOS — add to ~/.bashrc or ~/.zshrc
export PATH=$PATH:/usr/local/go/bin

# Windows — PATH is set automatically by the MSI installer

⚠️ Run this in your own terminal or Node.js environment.

Verifying the Installation

install होने के बाद, यह पुष्टि करने के लिए कि toolchain सही से set up है और आपके पास कौन सा release है यह देखने के लिए terminal में 'go version' चलाएं। किसी भी project को शुरू करने से पहले यह सबसे तेज़ sanity check है, और यही वह command है जो ज़्यादातर bug reports पहले मांगती हैं।

उदाहरण: Verifying the Installation

bash
go version

⚠️ Run this in your own terminal or Node.js environment.

What Gets Installed

Go install करने पर आपको go command-line tool मिलता है, जो compiler, standard library source, formatter (gofmt), और dependency manager को एक ही download में bundle करता है -- उन languages के विपरीत जिन्हें compiler, package manager, और linter के लिए अलग-अलग installers चाहिए होते हैं।

यह single-tool philosophy Go project setup को सरल रखने वाली चीज़ों का हिस्सा है।

उदाहरण: What Gets Installed

markup
// Every Go file belongs to a package; main builds an executable
package main

// Import the fmt package
import "fmt"

// main is where the program starts running
func main() {
	// Print the values followed by a newline
	fmt.Println("If this compiles and runs, your Go installation works!")
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. go.dev/dl के बजाय किसी unofficial mirror से Go download करना, एक पुराने या छेड़छाड़ किए installer का जोखिम उठाते हुए।
  2. Go की bin directory को system PATH में जोड़ना भूल जाना, जिससे terminal में go command नहीं मिलता।
  3. पहले पुराने को हटाए बिना Go के कई टकराते versions साथ install करना, जिससे 'go version' गलत version report करता है।
चैप्टर सारांश
  • Go Windows, macOS, और Linux के लिए go.dev/dl पर आधिकारिक installer या package manager से install होता है।
  • install के बाद, go command आपके system PATH पर उपलब्ध होनी चाहिए।
  • 'go version' installed compiler version की पुष्टि करता है।
  • Modern Go (1.16+) को रोज़ाना के projects के लिए अब manually GOPATH configure करने की ज़रूरत नहीं।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.