InDrive - 1
- Tell about the map
go/maps - Can you read from a map in multiple threads?
go/maps - What is sync.Map?
go/sync - Have you had to run a profiler in production?
hr-behavioral/about-you - What happens in the code when you write
goand a goroutine?go/concurrency - What kinds of channels are there?
go/channels - What types of memory are there in Go?
go/memory-gc - What memory does the garbage collector work with?
go/memory-gc - What will this output?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { var strData string for i := 0; i < 10; i++ { strData += fmt.Sprintf("%d ", i) } fmt.Println(strData)}- What will this output?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { defer fmt.Println(1) time.Sleep(1 * time.Second) go fmt.Println(2) go fmt.Println(3)}- Is defer always called?
go/errors-panic - What will this output?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { ctx, _ := context.WithTimeout(context.Background(), 3*time.Second) time.Sleep(2950 * time.Millisecond) doDbRequest(ctx)}
func doDbRequest(ctx context.Context) { newCtx, _ := context.WithTimeout(ctx, 10*time.Second) timer := time.NewTimer(1 * time.Second)
select { case <-newCtx.Done(): fmt.Println("Timeout ") case <-timer.C: fmt.Println("Request Done ") }}- What will this output?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»var counter = 0
func main() { for i := 0; i < 10; i++ { go func() { counter++ }() }
time.Sleep(2 * time.Second) fmt.Println(counter)}- There are three goroutines where run is blocked. How to make the steady function simultaneously unblock all three runs?
go/concurrency
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func runnerStart() { go ready() go ready() go ready()
steady() // ensure they start running after the call, simultaneously}
func steady() { // write}
func ready() { // wait for steady call run()}- Complete the code so that the task runs asynchronously with a limit on the number of simultaneous requests
go/concurrency
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { // Make this code asynchronous with controlled parallel request numbers for _, val := range getData() { if !checkDomain(val) { fmt.Printf("%s is bad \n ", val) } }}
func getData() []string { return []string{"1.test ", "2.test " /*...*/, "1000.test "}}
func checkDomain(host string) bool { return true}- Merge two sorted arrays
go/slices-arrays
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { // a, b - sorted slices var a = []int{1, 5, 6, 18, 99} var b = []int{2, 4, 9, 11}
fmt.Println(mergeSorted(a, b))}
func mergeSorted(a []int, b []int) { // write}- There is a method that iterates through all records from a table by increasing the offset. What problems do you see?
sql/query-optimization
Задача: (код без описания) sql/general
Заголовок раздела «Задача: (код без описания) sql/general»select*from news where category_id =1 limit 10 offset 100;- Question about indexes
sql/indexes - What does B in B-Tree index stand for
sql/indexes - Question about escaping in SQL queries
sql/general - Question about locking in SQL
sql/general - Explain ACID
sql/transactions - Have you heard of deadlocks in databases?
go/sync - What is sharding?
sql/replication-scaling
Задача: Describe methods, speed up data retrieval. The task depends on the dialogue. algorithms/data-structures
Заголовок раздела «Задача: Describe methods, speed up data retrieval. The task depends on the dialogue. algorithms/data-structures»// building a weather app. Getting weather forecast by country.// Data updates come infrequently relative to reads and irregularly.// A 2-hour data lag is acceptable// The DB works poorly and slowly, 700-800ms
type database interface { get(ctx context.Context, key string) (string, error) save(ctx context.Context, key, value string) error}
type Repository struct { db database}
func (r *Repository) Get(ctx context.Context, key string) (string, error) { return r.db.get(ctx, key)}
func (r *Repository) Save(ctx context.Context, key, value string) error { return r.db.save(ctx, key, value)}