Go

Advanced Go

Compiler internals, runtime, scheduler, cgo, unsafe package, assembly, build tags

20 mülakat soruları·
Senior
1

Which Go toolchain tool allows inspecting the assembly code generated by the compiler?

Cevap

The go tool compile -S command displays the assembly code generated by the Go compiler. This tool is essential for understanding compiler optimizations and analyzing performance-critical code. It is also possible to use go build -gcflags=-S to achieve the same result during a standard build.

2

What is the main purpose of the unsafe package in Go?

Cevap

The unsafe package allows bypassing Go's type system to perform low-level memory operations. It exposes functions like Pointer, Sizeof, Alignof, and Offsetof that enable direct memory address manipulation. Its use is discouraged except for specific cases like interoperability with C code or critical optimizations.

3

How does the Go scheduler (GPM) organize goroutine execution?

Cevap

The Go scheduler uses the GPM model: G represents goroutines, P represents logical processors (GOMAXPROCS), and M represents system threads. Each P has a local run queue of goroutines. When an M is blocked on a syscall, the P can be detached and associated with another M to continue goroutine execution. This design enables efficient scheduling with minimal context switches.

4

What is cgo and in which context should it be used?

5

Which directive allows conditionally compiling code based on target OS or architecture?

+17 mülakat soruları

Bir sonraki mülakatın için Go'de uzmanlaş

Tüm sorulara, flashcards'a, teknik testlere, code review alıştırmalarına ve mülakat simülatörlerine eriş.

Ücretsiz başla