Go इंस्टॉल करना
In this page:
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 के अंदर चलने वाली कोई चीज़ नहीं है।
उदाहरण: Downloading the Go Toolchain
# 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 करता है।
उदाहरण: Adding Go to your PATH
# 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
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
// 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!")
}
Login to try C/C++/Java/PHP code in the editor
- go.dev/dl के बजाय किसी unofficial mirror से Go download करना, एक पुराने या छेड़छाड़ किए installer का जोखिम उठाते हुए।
- Go की bin directory को system PATH में जोड़ना भूल जाना, जिससे terminal में go command नहीं मिलता।
- पहले पुराने को हटाए बिना 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: