Skip to content

Commit 476d86f

Browse files
author
Rajeev Kumar Singh
committed
Package examples
1 parent 55266b1 commit 476d86f

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

07-packages/app/main.go renamed to 07-packages/app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"fmt"
55
"github.com/callicoder/golang-tutorials/07-packages/numbers"
6-
"github.com/callicoder/golang-tutorials/07-packages/strings"
6+
"github.com/callicoder/golang-tutorials/07-packages/strings"
77
"github.com/callicoder/golang-tutorials/07-packages/strings/greetings" // Importing a nested package
88
str "strings" // Package Alias
99
)

07-packages/main/main.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"time"
6+
"math"
7+
"math/rand"
8+
)
9+
10+
func main() {
11+
// Finding the Max of two numbers
12+
fmt.Println(math.Max(73.15, 92.46))
13+
14+
// Calculate the square root of a number
15+
fmt.Println(math.Sqrt(225))
16+
17+
// Printing the value of `𝜋`
18+
fmt.Println(math.Pi)
19+
20+
// Epoch time in milliseconds
21+
epoch := time.Now().Unix()
22+
fmt.Println(epoch)
23+
24+
// Generating a random integer between 0 to 100
25+
rand.Seed(epoch)
26+
fmt.Println(rand.Intn(100))
27+
}

07-packages/numbers/prime.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ func IsPrime(num int) bool {
99
return false
1010
}
1111
}
12-
1312
return num > 1
1413
}

07-packages/strings/greetings/texts.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
package greetings
33

44
// Exported
5-
const WelcomeText = "Hello, World to Golang"
6-
const MorningText = "Good Morning"
7-
const EveningText = "Good Evening"
5+
const (
6+
WelcomeText = "Hello, World to Golang"
7+
MorningText = "Good Morning"
8+
EveningText = "Good Evening"
9+
)
810

911
// Not exported (only visible inside the `greetings` package)
1012
var loremIpsumText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit,

0 commit comments

Comments
 (0)