Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// 1. Greet a few people
|
||||
// 2. Try to type your statements separating them using
|
||||
// semicolons
|
||||
// 3. Observe how Go fixes them for you
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
// uncomment the below line of code; then save the file
|
||||
//
|
||||
// you will see that Go will fix it automatically
|
||||
//
|
||||
// this is because, for Go, it doesn't matter whether
|
||||
// you use semicolons between statements or not.
|
||||
//
|
||||
// it adds them automatically after all.
|
||||
|
||||
// fmt.Println("inanc"); fmt.Println("lina"); fmt.Println("ebru");
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// Try to type just "Hello" on a line.
|
||||
// Do not use Println
|
||||
// Observe the error
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
// ?
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
// uncomment to see the error
|
||||
|
||||
// "Hello"
|
||||
|
||||
// It says "evaluted but not used" because
|
||||
// the "Hello" expression returned a value
|
||||
// and no statement has used it
|
||||
|
||||
// You can't use expressions without statements
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// Print the expected output using operators
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// "Hello!!!?"
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
// use + operator below multiple times
|
||||
// fmt.Println("Hello!" + ?)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// Operators bind multiple expressions together
|
||||
// as if there's a single expression
|
||||
fmt.Println("Hello!" + "!" + "!" + "?")
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// 1- Look at runtime package documentation
|
||||
// 2- Find the func that returns the Go version
|
||||
// 3- Print the Go version by calling that func
|
||||
//
|
||||
// HINT
|
||||
// It's here: https://golang.org/pkg/runtime
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// "go1.10"
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
// ?
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(runtime.Version())
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// Use single and multiline comments to comment Printlns
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// None
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello")
|
||||
fmt.Println("how")
|
||||
fmt.Println("are")
|
||||
fmt.Println("you")
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
// fmt.Println("hello")
|
||||
/*
|
||||
fmt.Println("how")
|
||||
fmt.Println("are")
|
||||
fmt.Println("you")
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// 1- Print the documentation of runtime.NumCPU function
|
||||
// in the command line
|
||||
//
|
||||
// 2- Print also its source code using in the command line
|
||||
//
|
||||
// HINT
|
||||
// You should use correct go doc tools
|
||||
// ---------------------------------------------------------
|
||||
@@ -0,0 +1,7 @@
|
||||
## DOCUMENTATION:
|
||||
|
||||
go doc runtime NumCPU
|
||||
|
||||
## SOURCE CODE:
|
||||
|
||||
godoc -src runtime NumCPU
|
||||
Reference in New Issue
Block a user