Ans: Go is an open-source programming language developed by Google, designed for efficient and concurrent system programming.
Ans: Go features include simplicity, efficiency, built-in concurrency, garbage collection, strong typing, and a rich standard library.
Ans: Goroutines are lightweight threads in Go that allow concurrent execution of functions, enabling efficient concurrent programming.
Ans: Go uses explicit error handling by returning errors as values. Developers typically check for errors and handle them accordingly.
Ans: Channels are used for communication and synchronization between goroutines. They allow safe data exchange and coordination.
Ans: "defer" is used to schedule a function call to be executed when the surrounding function completes, while "panic" is used to trigger a runtime error.
Ans: Go provides a built-in testing package. Unit tests are written as functions with names beginning with "Test" and can be executed using the "go test" command.
Ans: A pointer in Go is a variable that holds the memory address of another value. It is used to indirectly access and modify data.
Ans: A slice is a dynamic and flexible wrapper over an array. It allows efficient and convenient operations on sequences of data.
Ans: Go has a garbage collector that automatically manages memory allocation and deallocation, freeing developers from manual memory management tasks.
Ans: Interfaces in Go define a set of methods that a type must implement. They allow polymorphism and help achieve loose coupling in code.
Ans: Go provides goroutines and channels for concurrent programming. Goroutines allow lightweight concurrency, and channels facilitate communication and synchronization between goroutines.
Ans: Go provides synchronization primitives like mutexes and atomic operations to prevent race conditions. Proper use of these mechanisms helps ensure safe concurrent access to shared data.
Ans: A struct is a composite data type that can contain named fields of different types, while an array is a fixed-size collection of elements of the same type.
Ans: A value receiver in Go operates on a copy of the value, while a pointer receiver operates on the actual value. Pointer receivers can modify the value they point to.
Ans: Go provides a "time" package that allows setting timeouts for operations. Timers and contexts can be used to implement timeouts effectively.
Ans: The init() function is a special function in Go that is executed automatically before the program starts. It is often used for initialization tasks.
Ans: Go's "os" and "io" packages provide functions for file handling and I/O operations. Developers can open, read, write, and manipulate files using these packages.
Ans: "defer" schedules a function call to be executed when the surrounding function completes, "panic" triggers a runtime error, and "recover" is used to catch and handle panics.
Ans: Go provides the "encoding/json" package for JSON operations. It allows encoding Go data structures to JSON and decoding JSON into Go types.
Ans: The blank identifier () is used to discard values returned by a function when you are not interested in using or assigning them.
Ans: Go provides synchronization primitives such as mutexes, read/write locks, and atomic operations to handle concurrent access to shared resources safely.
Ans: Go promotes explicit error handling by returning errors as values. It encourages developers to check and handle errors, improving code reliability and robustness.
Ans: The "go mod" command is used for managing dependencies in Go projects. It allows developers to define and manage dependencies using a go.mod file.
Ans: Defer chaining is the ability to stack multiple deferred function calls. When a function with deferred calls completes, the deferred functions are executed in a "last in, first out" order.