Golang : Quiz, Questions, Mock Test
Golang : Quiz, Questions, Mock Test
Course Content
🏗️ Introduction to Golang
🔍 What is Golang?
🔹 Golang (or Go) is an open-source programming language designed for efficiency and simplicity.
📜 History of Golang
🔹 Developed by Google in 2007
🔹 Released publicly in 2009
⚡ Features of Go
🔹 Statically typed & compiled
🔹 Garbage collection
🔹 Concurrency support
🔹 Cross-platform compatibility
🔧 Installation of Go
🔹 Download from golang.org
🔹 Install via package managers (brew, apt, etc.)
🛠️ Setting Up Go Development Environment
🔹 Configure
GOPATH🔹 Setup
GOROOT
▶️ Running a Go Program
go run main.go🔤 Go Basics
📌 Variables & Constants
var name string = "John"
const pi = 3.14🔠 Data Types
🔹
int,float64,string,bool, etc.
✍️ Type Inference
name := "Alice"🖨️ Printing Output
fmt.Println("Hello, Go!")🔄 Taking Input
fmt.Scan(&name)🔢 Go Operators
🔹 Arithmetic Operators
🔹 Comparison Operators
🔹 Logical Operators
🔹 Bitwise Operators
🔹 Assignment Operators
🔀 Go Control Flow
✅ If-Else Statements
if age >= 18 {
fmt.Println("Adult")
} else {
fmt.Println("Minor")
}🔄 Switch Statements
🔁 Loops (for, range, break, continue)
⏩ Goto Statements
🔧 Go Functions
🔨 Defining Functions
func add(a int, b int) int {
return a + b
}🛠️ Multiple Return Values
📌 Named Return Values
✨ Variadic Functions
🔄 Anonymous Functions
🔗 Higher-Order Functions
🗂️ Go Arrays & Slices
📌 Declaring Arrays
var arr = [3]int{1, 2, 3}📋 Slices (make(), append(), copy())
🔄 Iterating Over Arrays & Slices
📏 Multi-Dimensional Arrays
🗺️ Go Maps (Dictionaries)
📌 Declaring Maps
var myMap = map[string]int{"apple": 2, "banana": 3}➕ Adding & Removing Keys
🔍 Checking Key Existence
🔄 Iterating Over Maps
🏗️ Go Structs & Methods
📦 Defining Structs
type Person struct {
Name string
Age int
}⚙️ Struct Methods
🔗 Embedded Structs
🔎 Comparing Structs
📌 Go Pointers
🔹 Understanding Pointers (
*,&)🔹 Pointer Arithmetic
🔹 Passing Pointers to Functions
🔹 Pointer vs Value Receivers
🔌 Go Interfaces
📌 Declaring Interfaces
type Animal interface {
Speak() string
}🛠️ Implementing Interfaces
🔍 Type Assertions & Type Switch
🚀 Go Concurrency
🏃 Goroutines
go myFunction()🔄 WaitGroups
🔐 Mutex & Locks
🔗 Channels (make(chan int))
📤 Buffered & Unbuffered Channels
🔄 Select Statement
📂 Go File Handling
🔹 Reading & Writing Files
🔹 Handling JSON & XML Files
🔹 Using
ioandbufioPackage
❗ Go Error Handling
🔹 Handling Errors with
errorInterface🔹 Custom Error Types
🔹 Using
recover()for Panic Recovery🔹
deferStatements
📜 Go Logging & Debugging
🔹 Using
logPackage🔹 Custom Log Formatting
🔹 Debugging with
delve
🧪 Go Unit Testing
🔹 Writing Unit Tests (
testingpackage)🔹 Running Tests (
go test)🔹 Table-Driven Tests
🔹 Benchmarking in Go
📦 Go Packages & Modules
🔹 Creating & Using Packages
🔹 Importing External Packages
🔹 Managing Dependencies with
go mod🔹 Writing Reusable Modules
🌐 Go Web Development
🔹 Building REST APIs with
net/http🔹 Working with JSON
🔹 Using
Gorilla Muxfor Routing🔹 Middleware in Go
🛢️ Go Database Integration
🔹 Connecting to MySQL & PostgreSQL
🔹 Using
database/sqlPackage🔹 Using
GORMORM🔹 Performing CRUD Operations
🔐 Go Security Best Practices
🔹 Secure Coding Practices
🔹 Preventing SQL Injection
🔹 Handling Sensitive Data
🔹 HTTPS & TLS in Go
🚀 Go Deployment & Optimization
🔹 Compiling Go Code (
go build)🔹 Cross-Compilation for Different OS
🔹 Code Optimization & Profiling
🔹 Deploying Go Applications (Docker, Kubernetes)
📊 Sorting in Go
📌 Sorting an Array of Integers
package main
import (
"fmt"
"sort"
)
func main() {
numbers := []int{5, 2, 9, 1, 3}
sort.Ints(numbers)
fmt.Println("Sorted Numbers:", numbers) // Output: [1 2 3 5 9]
}📌 Sorting a Struct by a Field
package main
import (
"fmt"
"sort"
)
type Person struct {
Name string
Age int
}
func main() {
people := []Person{
{"Alice", 30},
{"Bob", 25},
{"Charlie", 35},
}
sort.Slice(people, func(i, j int) bool {
return people[i].Age < people[j].Age
})
fmt.Println("Sorted by Age:", people)
}🔹
🔹
🔹