Sobes.tech

func fn() { str := "" for i := 0; i < 100000; i++ { str += fmt.Sprintf("%d", i) } fmt.Println(str) }

195

On line 7, it is concluded that the internal array will be overflowed and a new one will be created. Why did you decide that?

175

// What will be printed on each print? func fn(a []int) { a[2] = 5 a = append(a, 6) fmt.Println(a) // a = append(a, 7) a[0] = 5 fmt.Println(a) // } func main() { a := make([]int, 0, 5) for i := 0; i < 4; i++ { a = append(a, i) } fn(a[:3]) fmt.Println(a) // }

175

What happens to the Token Bucket rate limiter in the scenario: 1 request at the beginning of the second, 99 at the end, then another 100 in the next second?

168

// what's wrong with this code? how to improve it? func fn() { str := "" for i := 0; i < 100000; i++ { str += fmt.Sprintf("%d", i) } fmt.Println(str) }

165

// what will be printed on each print? func fn(a []int) { a[2] = 5 a = append(a, 6) fmt.Println(a) // a = append(a, 7) a[0] = 5 fmt.Println(a) // } func main() { a := make([]int, 0, 5) for i := 0; i < 4; i++ { a = append(a, i) } fn(a[:3]) fmt.Println(a) // }

153
/4