Skip to content

Commit fa48013

Browse files
committed
Merge branch 'develop'
2 parents 55376d5 + 751c2e0 commit fa48013

File tree

14 files changed

+144
-13
lines changed

14 files changed

+144
-13
lines changed

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,16 @@ This training kit has been developed for those who already have the basic knowle
44

55
## Table of content
66

7-
* Session 1: Introduction to Go & development environment. Visit: http://slides.com/ashwinhegde/learn-go-lang/fullscreen
8-
* Session 2: Variables, Types, Pointers and Constants.
9-
* Session 3: Functions.
10-
* Session 4: Branching & Loops.
11-
* Session 5: Maps, Slices.
12-
* Session 6: Methods & Interface.
13-
* Session 7: Concurrency.
14-
* Session 8: Web Application.
15-
* Session 9: Introduction to Martini - Go web framework.
7+
* Introduction to Go & development environment. Visit: http://slides.com/ashwinhegde/learn-go-lang/fullscreen
8+
* Session 1: Variables, Types, Pointers and Constants.
9+
* Session 2: Functions.
10+
* Session 3: Branching & Loops.
11+
* Session 4: Maps, Slices.
12+
* Session 5: Methods & Interface.
13+
* Session 6: Concurrency.
1614

1715
## Author & Contributors
1816

19-
Developed & maintained by author: Ashwin Hegde
20-
21-
Follow me at: [github](https://github.com/hegdeashwin) | [Linkedin](http://in.linkedin.com/in/hegdeashwin) | [Twitter](https://twitter.com/hegdeashwin3)
22-
2317
We really appreciate all kind of contributions. Special thanks to <a href="//github.com/hegdeashwin/learning-go-lang/graphs/contributors" target="_blank">contributors</a> for using and supporting learning-go-lang.
2418

2519
To request a feature or you find any typo errors, enhancements or questions; please feel free to post it on following link, or vote for the ones that are already registered.
File renamed without changes.

codes/session-1/helloworld.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Declare the file as main package.
3+
*/
4+
package main
5+
6+
/**
7+
* import format;
8+
*/
9+
import "fmt"
10+
11+
/**
12+
* Main function acts as a single entry point.
13+
*/
14+
func main() {
15+
16+
/**
17+
* Print a message
18+
*/
19+
fmt.Println("Hello World");
20+
21+
/**
22+
* Declare a variable with string type and assign a string value to it;
23+
* Type is optional.
24+
*/
25+
var message string
26+
message = "Welcome to Go World!"
27+
28+
fmt.Println(message);
29+
30+
/**
31+
* Declare multiple variables with integer type and assign a integer values to them;
32+
* Type is optional.
33+
*/
34+
var a, b, c int = 1, 2, 3
35+
36+
fmt.Println(a, b, c);
37+
38+
/**
39+
* Declare a variable and assign a string value to it with short way;
40+
*/
41+
name := "Ashwin Hegde"
42+
43+
fmt.Println(name)
44+
45+
46+
}

codes/session-1/pointer.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
7+
/**
8+
* Created message variable and assigned string to it.
9+
*/
10+
message := "Hello World"
11+
12+
/**
13+
* Created greeting string pointer to hold the memory address of message variable
14+
*/
15+
var greeting *string = &message
16+
17+
/**
18+
* Print message
19+
*/
20+
fmt.Println(message)
21+
22+
/**
23+
* Print greeting memory address
24+
*/
25+
fmt.Println(greeting)
26+
27+
/**
28+
* Print value of greeting
29+
*/
30+
fmt.Println(*greeting)
31+
32+
/**
33+
* Change pointer value, also change message value
34+
*/
35+
*greeting = "Welcome to the Go world!"
36+
37+
fmt.Println(message);
38+
39+
fmt.Println(*greeting);
40+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package main
2+
3+
import "fmt"
4+
5+
/**
6+
* User defined type customString act as string type
7+
*/
8+
type customString string
9+
10+
/**
11+
* User defined type userInfo act as struct type
12+
*/
13+
type userInfo struct {
14+
name string
15+
greeting string
16+
}
17+
18+
func main() {
19+
20+
/**
21+
* Use customString as type
22+
*/
23+
var message customString = "Hello World!"
24+
fmt.Println(message)
25+
26+
/**
27+
* 1 way: Assign values to userInfo struct
28+
*/
29+
var defaults = userInfo{};
30+
defaults.name = "Unknown"
31+
defaults.greeting = "Welcome"
32+
33+
fmt.Println(defaults.name)
34+
fmt.Println(defaults.greeting)
35+
36+
/**
37+
* 2 way: Assign values to userInfo struct; Go by order
38+
*/
39+
var facebookProfile = userInfo{"Ashwin", "Hello!"}
40+
41+
fmt.Println(facebookProfile.name)
42+
fmt.Println(facebookProfile.greeting)
43+
44+
/**
45+
* 3 way: Assign values to userInfo struct; Go by member name
46+
*/
47+
var linkedinProfile = userInfo{greeting: "Hello Go!", name: "Ashwin Hegde"}
48+
49+
fmt.Println(linkedinProfile.name)
50+
fmt.Println(linkedinProfile.greeting)
51+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)