Golang Questions et reponses d'entretien
Differences associees
Question 21. What is the difference between a 'slice' and an 'array' in Go?
Arrays have a fixed size defined at compile-time, while slices are dynamic and can change in size during runtime. Slices are built on top of arrays and offer more flexibility.
Question 22. Explain the concept of defer chaining in Go.
In Go, multiple 'defer' statements can be stacked or chained together. They are executed in the reverse order of their appearance, meaning the last 'defer' statement is executed first.
Question 23. How does Go handle race conditions?
Go uses the 'sync' package and the 'mutex' (Mutual Exclusion) concept to handle race conditions. Mutexes ensure that only one goroutine can access a shared resource at a time.
Question 24. What is the purpose of the 'range' keyword in Go?
The 'range' keyword is used in for loops to iterate over items in an array, slice, map, channel, or string. It simplifies the code for iterating over elements.
Question 25. Explain the concept of anonymous functions in Go.
Anonymous functions, also known as function literals, are functions without a name. They can be defined and invoked inline, making them useful for short-lived and one-time-use functions.
Les plus utiles selon les utilisateurs :