Skip to content

Instantly share code, notes, and snippets.

@minhphong306
Created September 11, 2025 06:22
Show Gist options
  • Save minhphong306/2c8ad2f88126d4259fc69a89717e3938 to your computer and use it in GitHub Desktop.
Save minhphong306/2c8ad2f88126d4259fc69a89717e3938 to your computer and use it in GitHub Desktop.
middle-golang-interview-questions.md

Core Golang Concepts

1. Goroutines & Concurrency

  • Goroutines là gì, khác gì với thread
  • Channel (buffered vs unbuffered)
  • Select statement
  • WaitGroup, Mutex, RWMutex
  • Race condition và cách xử lý
  • Context package và cách sử dụng

2. Data Types & Structures

  • Slice vs Array (capacity, length, append)
  • Map internals và khi nào map không an toàn
  • Pointer và khi nào nên dùng pointer
  • Interface{} và type assertion
  • Struct embedding và composition

3. Interface & Methods

  • Interface satisfaction (implicit)
  • Empty interface
  • Method với pointer receiver vs value receiver
  • Interface segregation principle

4. Error Handling

  • Error wrapping (fmt.Errorf với %w)
  • Custom error types
  • Panic, recover, defer
  • Best practices cho error handling

5. Memory Management

  • Garbage collection trong Go
  • Stack vs Heap allocation
  • Memory leak common cases
  • Escape analysis

Practical Topics

6. Testing

  • Unit test, benchmark test
  • Table-driven tests
  • Mocking và interface
  • Coverage testing

7. Common Packages

  • net/http cho web server
  • encoding/json
  • database/sql
  • Popular frameworks: Gin, Echo, Fiber

8. Design Patterns

  • Singleton, Factory
  • Worker pool pattern
  • Fan-in, Fan-out pattern
  • Pipeline pattern

9. Best Practices

  • Code organization (package structure)
  • Naming conventions
  • Error handling patterns
  • Dependency injection

Câu hỏi thường gặp

  1. Goroutine leak là gì? Cách phát hiện và xử lý?
  2. Khi nào dùng channel, khi nào dùng mutex?
  3. Giải thích về nil interface và nil pointer
  4. Làm sao để handle graceful shutdown?
  5. Cách optimize performance trong Go?

Coding Challenges có thể gặp

  • Implement worker pool
  • Rate limiter
  • Concurrent safe cache
  • Simple HTTP server với middleware
  • Database connection pooling
@minhphong306
Copy link
Author

Đối với Mid mình nghĩ bạn nên xoáy sâu về phần GMP cách thức nó hoạt động, Garbage Collection và Design System nếu có

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment