|
1462 | 1462 |
|
1463 | 1463 | 15. ### What are channels for? |
1464 | 1464 |
|
1465 | | - Channels are the pipes that connect concurrent goroutines. You can send values into channels from one goroutine and receive those values into another goroutine. |
| 1465 | + Channels are the pipes that connect concurrent goroutines. You can send values into channels from one goroutine and receive those values into another goroutine. |
1466 | 1466 |
|
1467 | | - **[ Back to Top ⬆ ](#table-of-contents---golang)** |
| 1467 | + **[ Back to Top ⬆ ](#table-of-contents---golang)** |
1468 | 1468 |
|
1469 | 1469 | 16. ### Can you do something in goroutines using channels? |
1470 | | - * Channels are goroutine-safe and can store and pass values between goroutines |
1471 | | - * Channels provide FIFO semantics. |
1472 | | - * Channels cause goroutines to block and unblock, which we just learned about. |
| 1470 | + * Channels are goroutine-safe and can store and pass values between goroutines |
| 1471 | + * Channels provide FIFO semantics. |
| 1472 | + * Channels cause goroutines to block and unblock, which we just learned about. |
1473 | 1473 |
|
1474 | 1474 | **[ Back to Top ⬆ ](#table-of-contents---golang)** |
1475 | 1475 |
|
1476 | 1476 | 17. ### What is a Closure? |
1477 | 1477 |
|
1478 | | - A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables |
| 1478 | + A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables.<br/> |
1479 | 1479 |
|
1480 | 1480 | **[ Back to Top ⬆ ](#table-of-contents---golang)** |
1481 | 1481 |
|
1482 | 1482 | 18. ### What are runtime and runtime packages? |
1483 | 1483 |
|
1484 | | - The runtime library implements garbage collection, concurrency, stack management, and other critical features of the Go language. The Package runtime contains operations that interact with Go's runtime system, such as functions to control goroutines. |
| 1484 | + The runtime library implements garbage collection, concurrency, stack management, and other critical features of the Go language. The Package runtime contains operations that interact with Go's runtime system, such as functions to control goroutines. |
1485 | 1485 | |
1486 | 1486 | **[ Back to Top ⬆ ](#table-of-contents---golang)** |
1487 | 1487 |
|
1488 | 1488 | 19. ### How can you get how many cores your computer has? |
| 1489 | + With the help of runtime package |
1489 | 1490 | |
1490 | | - ```go |
| 1491 | + ```go |
1491 | 1492 | package main |
1492 | 1493 |
|
1493 | 1494 | import ( |
|
1498 | 1499 | func main() { |
1499 | 1500 | fmt.Println(runtime.NumCPU()) |
1500 | 1501 | } |
1501 | | - ``` |
| 1502 | + ``` |
1502 | 1503 | |
1503 | 1504 | **[ Back to Top ⬆ ](#table-of-contents---golang)** |
1504 | 1505 |
|
|
1625 | 1626 | * Loosely coupled |
1626 | 1627 | * Independently deployable |
1627 | 1628 | * Organized around business capabilities |
1628 | | - * Owned by a small team |
| 1629 | + * Owned by a small team <br/> |
1629 | 1630 |
|
1630 | | - **[ Back to Top ⬆ ](#table-of-contents---golang)** |
| 1631 | + **[ Back to Top ⬆ ](#table-of-contents---golang)** |
1631 | 1632 |
|
1632 | 1633 | 24. ### Why are there no classes in Go ? |
1633 | 1634 | |
|
1657 | 1658 |
|
1658 | 1659 |
|
1659 | 1660 | 26. ### How to generate a true random number in golang? |
1660 | | - The default number generator is deterministic, so it’ll produce the same sequence of numbers each time by default , so you need to seed it with different number you can do it with nano seconds like below |
| 1661 | + The default number generator is deterministic, so it’ll produce the same sequence of numbers each time by default , so you need to seed it with different number you can do it with nano seconds like below <br/> |
1661 | 1662 |
|
1662 | | - ```go |
1663 | | - package main |
1664 | | - import ( |
| 1663 | + ```go |
| 1664 | + package main |
| 1665 | + import ( |
1665 | 1666 | "fmt" |
1666 | 1667 | "math/rand" |
1667 | 1668 | "time" |
1668 | 1669 | ) |
1669 | | - func main(){ |
| 1670 | + func main(){ |
1670 | 1671 | s1 := rand.NewSource(time.Now().UnixNano()) |
1671 | 1672 | r1 := rand.New(s1) |
1672 | 1673 | fmt.Print(r1.Intn(100)) |
1673 | | - } |
1674 | | - ``` |
| 1674 | + } |
| 1675 | + ``` |
1675 | 1676 |
|
1676 | 1677 | **[ Back to Top ⬆ ](#table-of-contents---golang)** |
1677 | 1678 |
|
|
0 commit comments