
Channels
Channels, buffered vs unbuffered, close, select, range over channels, nil channels
1What is a channel in Go?
What is a channel in Go?
Відповідь
A channel is a data type that enables communication and synchronization between goroutines. It acts as a typed conduit allowing sending and receiving values in a thread-safe manner. Use channels to share data between goroutines instead of sharing memory directly.
2How to create an unbuffered channel of integers in Go?
How to create an unbuffered channel of integers in Go?
Відповідь
An unbuffered channel is created with make(chan T) without specifying capacity. It blocks the sender until a receiver is ready, ensuring strict synchronization. Use unbuffered channels for one-to-one communications requiring explicit synchronization.
3What is the main difference between a buffered and an unbuffered channel?
What is the main difference between a buffered and an unbuffered channel?
Відповідь
An unbuffered channel blocks the sender until a receiver is ready (strict synchronization), while a buffered channel can store values up to its capacity before blocking. Buffered channels decouple goroutines and improve performance in some cases, but can hide concurrency issues. Use unbuffered for synchronization, buffered for throughput.
How to create a buffered channel with a capacity of 10 elements?
How to send a value into a channel?
+19 питань зі співбесід
Інші теми співбесід Go
Go Basics
Go Data Structures
Go Interfaces
Error Handling
Goroutines Basics
Go Modules
HTTP Server
HTTP Client
JSON Encoding
database/sql
Context Package
Testing
Concurrency Patterns
Sync Primitives
Go Web Frameworks
REST API Design
gRPC
Reflection
Memory Management
Performance Optimization
Generics
Go Design Patterns
Microservices
Security & Authentication
Docker & Containerization
Kubernetes Basics
Advanced Go
CLI Development
Опануй Go для наступної співбесіди
Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.
Почни безкоштовно