diff --git a/02-write-your-first-program/exercises/exercises.md b/02-write-your-first-program/exercises/README.md similarity index 81% rename from 02-write-your-first-program/exercises/exercises.md rename to 02-write-your-first-program/exercises/README.md index 9d0686c..8fbe96b 100644 --- a/02-write-your-first-program/exercises/exercises.md +++ b/02-write-your-first-program/exercises/README.md @@ -1,6 +1,6 @@ -1. Print your name and your best friend's name using Println twice. [Check out this challenge here](https://github.com/inancgumus/learngo/tree/master/02-write-your-first-program/exercises/01). +1. **Print your name and your best friend's name** using Println twice. [Check out this exercise here](https://github.com/inancgumus/learngo/tree/master/02-write-your-first-program/exercises/01). -2. Print your GOPATH using `go env` tool. [Check out this challenge here](https://github.com/inancgumus/learngo/tree/master/02-write-your-first-program/exercises/02). +2. **Print your GOPATH** using `go env` tool. [Check out this exercise here](https://github.com/inancgumus/learngo/tree/master/02-write-your-first-program/exercises/02). 3. **Say hello to yourself.** diff --git a/03-packages-and-scopes/exercises/01-packages/main.go b/03-packages-and-scopes/exercises/01-packages/main.go index 4d10ef8..a7cb111 100644 --- a/03-packages-and-scopes/exercises/01-packages/main.go +++ b/03-packages-and-scopes/exercises/01-packages/main.go @@ -8,7 +8,8 @@ package main // --------------------------------------------------------- -// EXERCISE +// EXERCISE: Use your own package +// // Create a few Go files and call their functions from // the main function. // diff --git a/03-packages-and-scopes/exercises/02-scopes/main.go b/03-packages-and-scopes/exercises/02-scopes/main.go index f6419da..25b8a91 100644 --- a/03-packages-and-scopes/exercises/02-scopes/main.go +++ b/03-packages-and-scopes/exercises/02-scopes/main.go @@ -8,7 +8,8 @@ package main // --------------------------------------------------------- -// EXERCISE +// EXERCISE: Try the scopes +// // 1. Create two files: main.go and printer.go // // 2. In printer.go: @@ -24,9 +25,6 @@ package main // 4. In printer.go: // 1. Call the bye function from // inside the hello function -// -// 5. In main.go: -// 1. // --------------------------------------------------------- func main() { diff --git a/03-packages-and-scopes/exercises/03-importing/main.go b/03-packages-and-scopes/exercises/03-importing/main.go index 171756d..ce80564 100644 --- a/03-packages-and-scopes/exercises/03-importing/main.go +++ b/03-packages-and-scopes/exercises/03-importing/main.go @@ -8,7 +8,8 @@ package main // --------------------------------------------------------- -// EXERCISE +// EXERCISE: Rename imports +// // 1- Import fmt package three times with different names // // 2- Print a few messages using those imports diff --git a/04-statements-expressions-comments/exercises/01/main.go b/04-statements-expressions-comments/exercises/01-shy-semicolons/main.go similarity index 72% rename from 04-statements-expressions-comments/exercises/01/main.go rename to 04-statements-expressions-comments/exercises/01-shy-semicolons/main.go index e96ea8a..e623c6c 100644 --- a/04-statements-expressions-comments/exercises/01/main.go +++ b/04-statements-expressions-comments/exercises/01-shy-semicolons/main.go @@ -8,11 +8,13 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1. Greet a few people -// 2. Try to type your statements separating them using +// EXERCISE: Shy Semicolons +// +// 1. Try to type your statements by separating them using // semicolons -// 3. Observe how Go fixes them for you +// +// 2. Observe how Go fixes them for you +// // --------------------------------------------------------- func main() { diff --git a/04-statements-expressions-comments/exercises/01-shy-semicolons/solution/main.go b/04-statements-expressions-comments/exercises/01-shy-semicolons/solution/main.go new file mode 100644 index 0000000..dd7a97d --- /dev/null +++ b/04-statements-expressions-comments/exercises/01-shy-semicolons/solution/main.go @@ -0,0 +1,23 @@ +// 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 line of code below; 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 the statements or not. + // + // It adds them automatically after all. + + /* + fmt.Println("inanc"); fmt.Println("lina"); fmt.Println("ebru"); + */ +} diff --git a/04-statements-expressions-comments/exercises/01/solution/main.go b/04-statements-expressions-comments/exercises/01/solution/main.go deleted file mode 100644 index f357e5b..0000000 --- a/04-statements-expressions-comments/exercises/01/solution/main.go +++ /dev/null @@ -1,21 +0,0 @@ -// 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"); -} diff --git a/04-statements-expressions-comments/exercises/02/main.go b/04-statements-expressions-comments/exercises/02-naked-expression/main.go similarity index 73% rename from 04-statements-expressions-comments/exercises/02/main.go rename to 04-statements-expressions-comments/exercises/02-naked-expression/main.go index 57a1cf1..652a070 100644 --- a/04-statements-expressions-comments/exercises/02/main.go +++ b/04-statements-expressions-comments/exercises/02-naked-expression/main.go @@ -8,10 +8,12 @@ package main // --------------------------------------------------------- -// EXERCISE -// Try to type just "Hello" on a line. -// Do not use Println -// Observe the error +// EXERCISE: Naked Expression +// +// 1. Try to type just "Hello" on a line. +// 2. Do not use Println +// 3. Observe the error +// // --------------------------------------------------------- func main() { diff --git a/04-statements-expressions-comments/exercises/02-naked-expression/solution/main.go b/04-statements-expressions-comments/exercises/02-naked-expression/solution/main.go new file mode 100644 index 0000000..cb13994 --- /dev/null +++ b/04-statements-expressions-comments/exercises/02-naked-expression/solution/main.go @@ -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 + +func main() { + // Uncomment the code line below to see the error. + + /* + "Hello" + */ + + // It will say: "evaluted but not used" + // + // Because: + // "Hello" literal returns a value but there isn't any + // statement which uses it. + // + // So: + // You can't use expressions alone without statements. +} diff --git a/04-statements-expressions-comments/exercises/02/solution/main.go b/04-statements-expressions-comments/exercises/02/solution/main.go deleted file mode 100644 index 3b3ed44..0000000 --- a/04-statements-expressions-comments/exercises/02/solution/main.go +++ /dev/null @@ -1,20 +0,0 @@ -// 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 -} diff --git a/04-statements-expressions-comments/exercises/03/main.go b/04-statements-expressions-comments/exercises/03-operators-combine/main.go similarity index 67% rename from 04-statements-expressions-comments/exercises/03/main.go rename to 04-statements-expressions-comments/exercises/03-operators-combine/main.go index 745645a..34eff78 100644 --- a/04-statements-expressions-comments/exercises/03/main.go +++ b/04-statements-expressions-comments/exercises/03-operators-combine/main.go @@ -8,14 +8,19 @@ package main // --------------------------------------------------------- -// EXERCISE -// Print the expected output using operators +// EXERCISE: Operators combine the expressions +// +// Print the expected output below using the string +// concatenation operator. +// +// HINT +// Use + operator multiple times to create "Hello!!!?". // // EXPECTED OUTPUT // "Hello!!!?" // --------------------------------------------------------- func main() { - // use + operator below multiple times + // fmt.Println("Hello!" + ?) } diff --git a/04-statements-expressions-comments/exercises/03/solution/main.go b/04-statements-expressions-comments/exercises/03-operators-combine/solution/main.go similarity index 75% rename from 04-statements-expressions-comments/exercises/03/solution/main.go rename to 04-statements-expressions-comments/exercises/03-operators-combine/solution/main.go index 5de119e..e8e2851 100644 --- a/04-statements-expressions-comments/exercises/03/solution/main.go +++ b/04-statements-expressions-comments/exercises/03-operators-combine/solution/main.go @@ -10,7 +10,7 @@ package main import "fmt" func main() { - // Operators bind multiple expressions together - // as if there's a single expression + // Operators combine multiple expressions together + // as if there's a single expression. fmt.Println("Hello!" + "!" + "!" + "?") } diff --git a/04-statements-expressions-comments/exercises/04/main.go b/04-statements-expressions-comments/exercises/04-print-go-version/main.go similarity index 70% rename from 04-statements-expressions-comments/exercises/04/main.go rename to 04-statements-expressions-comments/exercises/04-print-go-version/main.go index 2b9a614..e89ae42 100644 --- a/04-statements-expressions-comments/exercises/04/main.go +++ b/04-statements-expressions-comments/exercises/04-print-go-version/main.go @@ -8,10 +8,11 @@ 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 +// EXERCISE: Print the Go Version +// +// 1. Look at the 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 diff --git a/04-statements-expressions-comments/exercises/04/solution/main.go b/04-statements-expressions-comments/exercises/04-print-go-version/solution/main.go similarity index 100% rename from 04-statements-expressions-comments/exercises/04/solution/main.go rename to 04-statements-expressions-comments/exercises/04-print-go-version/solution/main.go diff --git a/04-statements-expressions-comments/exercises/05/main.go b/04-statements-expressions-comments/exercises/05-comment-out/main.go similarity index 76% rename from 04-statements-expressions-comments/exercises/05/main.go rename to 04-statements-expressions-comments/exercises/05-comment-out/main.go index 9282961..d159ffb 100644 --- a/04-statements-expressions-comments/exercises/05/main.go +++ b/04-statements-expressions-comments/exercises/05-comment-out/main.go @@ -10,11 +10,12 @@ package main import "fmt" // --------------------------------------------------------- -// EXERCISE -// Use single and multiline comments to comment Printlns +// EXERCISE: Comment out +// +// Use single and multiline comments to comment Printlns. // // EXPECTED OUTPUT -// None +// You shouldn't see any output after you're done. // --------------------------------------------------------- func main() { diff --git a/04-statements-expressions-comments/exercises/05/solution/main.go b/04-statements-expressions-comments/exercises/05-comment-out/solution/main.go similarity index 100% rename from 04-statements-expressions-comments/exercises/05/solution/main.go rename to 04-statements-expressions-comments/exercises/05-comment-out/solution/main.go diff --git a/04-statements-expressions-comments/exercises/06/exercise.md b/04-statements-expressions-comments/exercises/06-use-godoc/exercise.md similarity index 100% rename from 04-statements-expressions-comments/exercises/06/exercise.md rename to 04-statements-expressions-comments/exercises/06-use-godoc/exercise.md diff --git a/04-statements-expressions-comments/exercises/06/solution/solution.md b/04-statements-expressions-comments/exercises/06-use-godoc/solution/solution.md similarity index 100% rename from 04-statements-expressions-comments/exercises/06/solution/solution.md rename to 04-statements-expressions-comments/exercises/06-use-godoc/solution/solution.md