Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 61dd8ca

Browse files
adding sixth question
1 parent e935bf9 commit 61dd8ca

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

‎README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@
12591259
| 23 | [What are microservices?](#what-are-microservices)
12601260
| 24 | [Why are there no classes in Go?](#why-are-there-no-classes-in-go)
12611261
| 25 | [Difference between Compile time and runtime?](#difference-between-compile-time-and-runtime)
1262-
| 26 | [Do you need to convert the type of a variable of interface{} type passed in a function as an argument?](#do-you-need-to-convert-the-type-of-a-variable-of-interface{}-type-passed-in-a-function-as-an-argument)
1262+
| 26 | [How to generate a true random number in golang?](#how-to-generate-a-true-random-number-in-golang)
12631263
| 27 | [Why are goroutines light-weight?](#why-are-goroutines-light-weight)
12641264
| 28 | [If capacity is not defined in slice, what would the capacity be?](#if-capacity-is-not-defined-in-slice,-what-would-the-capacity-be)
12651265
| 29 | [What is the easiest way to check if a slice is empty?](#what-is-the-easiest-way-to-check-if-a-slice-is-empty)
@@ -1655,6 +1655,26 @@
16551655

16561656
**[ Back to Top ⬆ ](#table-of-contents---golang)**
16571657

1658+
1659+
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+
1662+
```go
1663+
package main
1664+
import (
1665+
"fmt"
1666+
"math/rand"
1667+
"time"
1668+
)
1669+
func main(){
1670+
s1 := rand.NewSource(time.Now().UnixNano())
1671+
r1 := rand.New(s1)
1672+
fmt.Print(r1.Intn(100))
1673+
}
1674+
```
1675+
1676+
**[ Back to Top ⬆ ](#table-of-contents---golang)**
1677+
16581678
### Table of Contents - Database Engineering
16591679

16601680

‎sentence_to_hashing_converter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ function hashing(num=0,str) {
2020
return `| ${num} | [${str}?](#${hashed})`
2121
}
2222

23-
console.log(hashing(30,'What is an advantage of Go evaluating implicit types at compile time'));
23+
console.log(hashing(26,'How to generate a true random number in golang'));

‎test.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11

2-
| 23 | [What are services in golang?](#what-are-services-in-golang)
3-
| 24 | [Why are there no classes in Go?](#why-are-there-no-classes-in-go)
4-
| 25 | [Difference between Compile time and runtime?](#difference-between-compile-time-and-runtime)
2+
53
| 26 | [Do you need to convert the type of a variable of interface{} type passed in a function as an argument?](#do-you-need-to-convert-the-type-of-a-variable-of-interface{}-type-passed-in-a-function-as-an-argument)
64
| 27 | [Why are goroutines light-weight?](#why-are-goroutines-light-weight)
75
| 28 | [If capacity is not defined in slice, what would the capacity be?](#if-capacity-is-not-defined-in-slice,-what-would-the-capacity-be)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /