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 5356eb0

Browse files
author
Rajeev Kumar Singh
committed
code restructuring
1 parent 4ad6a99 commit 5356eb0

File tree

38 files changed

+179
-29
lines changed

38 files changed

+179
-29
lines changed
File renamed without changes.
File renamed without changes.

‎03-basic-types/integers.go renamed to ‎03-basic-types/01-numeric-types/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package main
2+
23
import "fmt"
34

45
func main() {
@@ -15,5 +16,8 @@ func main() {
1516
var myHexNumber = 0xFF // Use prefix '0x' or '0X' for declaring hexadecimal numbers
1617
var myOctalNumber = 034 // Use prefix '0' for declaring octal numbers
1718

18-
fmt.Printf("%d, %d, %d, %#x, %#o\n", myInt8, myInt, myUint, myHexNumber, myOctalNumber)
19-
}
19+
var myFloat32 float32 = 4.5
20+
var myFloat = 9.12 // // Type inferred as `float64`
21+
22+
fmt.Printf("%d, %d, %d, %#x, %#o %f %f\n", myInt8, myInt, myUint, myHexNumber, myOctalNumber, myFloat32, myFloat)
23+
}
File renamed without changes.

‎03-basic-types/04-boolean-types/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
var myBoolean bool = true
7+
var anotherBoolean = false // Inferred type
8+
9+
var truth = 3 <= 5
10+
var falsehood = 10 != 10
11+
12+
// Short Circuiting
13+
var res1 = 10 > 20 && 5 == 5 // Second operand is not evaluated since first evaluates to false
14+
var res2 = 2*2 == 4 || 10%3 == 0 // Second operand is not evaluated since first evaluates to true
15+
16+
fmt.Println(myBoolean, anotherBoolean, truth, falsehood, res1, res2)
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
// === Creating complex numbers ====
7+
/*
8+
complex64: both real and imaginary parts are of float32 type.
9+
complex128: both real and imaginary parts are of float64 type.
10+
*/
11+
var x complex64 = 3.4 + 2.9i
12+
var y = 5 + 7i // Type inferred as `complex128` (default type for complex numbers)
13+
14+
fmt.Println(x, y)
15+
16+
// Creating complex no from variables
17+
var a1 = 4.5
18+
var a2 = 7.1
19+
20+
var c = complex(a1, a2) // a1 + a2*i won't work
21+
fmt.Println(c)
22+
23+
// ===== Complex No Operations =====
24+
var a = 3 + 5i
25+
var b = 2 + 4i
26+
27+
var res1 = a + b
28+
var res2 = a - b
29+
var res3 = a * b
30+
var res4 = a / b
31+
32+
fmt.Println(res1, res2, res3, res4)
33+
}

‎03-basic-types/strings.go renamed to ‎03-basic-types/06-strings/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package main
2+
23
import "fmt"
34

45
func main() {
6+
// Normal String (Can not contain newlines, and can have escape characters like `\n`, `\t` etc)
57
var website = "\thttps://www.callicoder.com\t\n"
68

9+
// Raw String (Can span multiple lines. Escape characters are not interpreted)
710
var siteDescription = `\t\tCalliCoder is a programming blog where you can find
811
practical guides and tutorials on programming languages,
912
web development, and desktop app development.\t\n`

0 commit comments

Comments
(0)

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