Uzum - 1
- What will this output and why?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() {s:="test "println(s[0])s[0] = 'A'println(s)}- What will this output and why?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { a := make(chan int, 1) for i := 0; i < 5; i++ { select { case <-a: fmt.Println(i) case a <- i: fmt.Println(i) } }}- What will this output?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { var arr = []int{1, 2, 3, 4, 5}
for i := range arr { defer fmt.Printf("%d ", arr[i]) }}And this way?
Explain why and why the output differs before and after Go v1.22. How to fix it if Go <v1.22.
- What will this output and why?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { slice := []string{"A ", "B ", "C "} addElem(slice[1:2], "X ") fmt.Println(slice)}
func addElem(slice []string, elem string) { slice = append(slice, elem)}- What will be the order and why?
go/puzzles
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»func main() { m := map[string]int{ "a ": 1, "b ": 2, "c ": 3, "d ": 4, }
for k, v := range m { fmt.Printf("Key: %s, Value: %d\n ", k, v) }
for k, v := range m { fmt.Printf("Key: %s, Value: %d\n ", k, v) }}- Live coding task: Implement a function that multiplexes channels and returns a result channel without waiting for them to merge.
go/channels
Задача: (код без описания) go/basics
Заголовок раздела «Задача: (код без описания) go/basics»// fan in / channel multiplexer / channel merge// takes all values from all input channels and writes them to the result channel// the pointer to the result channel must be obtained immediately// after all input channels close - the result channel must also be closedfunc merge(chans ...chan int) chan int { // write here}System design: design the architecture of a population census system for China.