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

Go परिचय

Go एक programming language है जिसे Google ने लोगों को बिना ढेर सारे confusing अतिरिक्त नियमों के computers के लिए साफ़, तेज़ instructions लिखने में मदद करने के लिए बनाया।

What is Go?

Go एक open-source, statically typed, compiled programming language है जिसे Google में design किया गया और 2009 में publicly release किया गया। यह किसी scripting language की तेज़ compilation और simplicity को किसी compiled language की performance और safety के साथ combine करती है।

Programs सीधे machine code में compile होते हैं, इसलिए runtime पर किसी अलग virtual machine या interpreter की ज़रूरत नहीं।

Note: आधिकारिक नाम Go है; Golang बस nickname है जो चिपक गया क्योंकि go.dev पहले से एक domain search term के रूप में लिया जा चुका था।

उदाहरण: What is Go?

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("Go is a statically typed, compiled language")
}

Why Go Was Created

Go के creators बड़े C++ codebases में धीमे builds, जटिल dependency management, और भ्रामक language features से निराश थे।

उन्होंने Go को जल्दी compile होने, एक छोटा और readable syntax रखने, और concurrent programming (एक साथ कई tasks handle करना) को out of the box सरल और सुरक्षित बनाने के लिए design किया। परिणाम एक ऐसी language है जो सीखना आसान है लेकिन बड़ी teams और systems के लिए अच्छी तरह scale करती है।

Note: तेज़ compile times एक founding goal थे -- Google में बड़े Go codebases को C++ में build होने में बहुत समय लगता था।

उदाहरण: Why Go Was Created

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() {
	// Short declaration: create goals and infer the type
	goals := []string{"fast compilation", "simple syntax", "built-in concurrency"}
	// Loop over goals; the blank identifier _ ignores the index
	for _, g := range goals {
		// Print the values followed by a newline
		fmt.Println("Design goal:", g)
	}
}

Where Go Is Used

Go अपनी speed, छोटे memory footprint, और आसान deployment (बिना external runtime के एक single binary) के कारण backend web servers, cloud और networking tools, और command-line utilities के लिए लोकप्रिय है।

Google, Uber, और Cloudflare जैसी companies performance-critical services के लिए Go उपयोग करती हैं। इसका built-in concurrency model इसे कई simultaneous network connections juggle करने वाले systems के लिए भी स्वाभाविक रूप से उपयुक्त बनाता है।

Note: Go में लिखे notable software में Docker, Kubernetes, और Terraform शामिल हैं।

उदाहरण: Where Go Is Used

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() {
	// Short declaration: create usedFor and infer the type
	usedFor := map[string]string{
		"Docker":     "container tooling",
		"Kubernetes": "container orchestration",
		"Terraform":  "infrastructure as code",
	}
	// Loop over usedFor, getting each index and value
	for tool, purpose := range usedFor {
		// Print using a format string
		fmt.Printf("%s: %s\n", tool, purpose)
	}
}

Compiled, Not Interpreted

Python या JavaScript के विपरीत, Go source code चलने से पहले ही एक standalone native executable में compile किया जाता है।

इसका मतलब है कि compiler आपके program शुरू होने से पहले ही कई गलतियां (जैसे type errors) पकड़ लेता है, और resulting binary उस machine पर बिना Go installed के चलता है जो इसे execute करती है। यह trade-off एक compile step की लागत लेता है लेकिन runtime speed और reliability में फायदा देता है।

उदाहरण: Compiled, Not Interpreted

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("This program is compiled into machine code before running")
	// Print the values followed by a newline
	fmt.Println("No interpreter is needed to execute the final binary")
}
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 को एक compiled, statically typed language के बजाय Python जैसी एक interpreted scripting language मानना।
  2. Go (language, कभी-कभी Golang कहा जाता है) को online मदद खोजते समय असंबंधित board game या दूसरे Go products के साथ confuse करना।
  3. Go के सरल struct + interface composition model के बजाय Java/C++ जैसी classes और inheritance की उम्मीद करना।
चैप्टर सारांश
  • Go एक statically typed, compiled language है जिसे Google में 2009 में Robert Griesemer, Rob Pike, और Ken Thompson ने बनाया।
  • यह simplicity को प्राथमिकता देती है: एक छोटा keyword set, तेज़ compilation, built-in concurrency, और automatic garbage collection।
  • Go एक single native binary में compile होता है, servers और containers में deployment को सीधा बनाते हुए।
  • यह backend services, cloud infrastructure (Docker, Kubernetes), और command-line tools के लिए व्यापक रूप से उपयोग होता है।
🔒

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.