From 48bf16c03535682ae1bf05136ccd0c5ebc5eb401 Mon Sep 17 00:00:00 2001 From: Inanc Gumus Date: Tue, 6 Nov 2018 01:29:53 +0300 Subject: [PATCH] fix: exercises for write your first library and variables find the rectangle area exercise --- 05-write-your-first-library-package/exercise/README.md | 10 +++++++++- .../exercises/04-find-the-rectangle-area/main.go | 8 ++++---- .../04-find-the-rectangle-area/solution/main.go | 6 +++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/05-write-your-first-library-package/exercise/README.md b/05-write-your-first-library-package/exercise/README.md index 4cc419c..2fa9985 100644 --- a/05-write-your-first-library-package/exercise/README.md +++ b/05-write-your-first-library-package/exercise/README.md @@ -19,4 +19,12 @@ func Version() string { ``` ## EXPECTED OUTPUT -It should print the current Go version on your system. \ No newline at end of file +It should print the current Go version on your system. + +## WARNING + +You should create this package under your own folder, not in github.com/inancgumus/learngo folder. Also, please note that, VS Code may automatically import my library which is in github.com/inancgumus/learngo instead of your own library. + +So, if you want VS Code automatically import your own package when you save, just move github.com/inancgumus/learngo out of GOPATH to somewhere else, for example, to your Desktop (of course move it back afterwards). + +See [this question](https://www.udemy.com/learn-go-the-complete-bootcamp-course-golang/learn/v4/questions/5518190) in Q&A for more information. \ No newline at end of file diff --git a/06-variables/04-assignment/exercises/04-find-the-rectangle-area/main.go b/06-variables/04-assignment/exercises/04-find-the-rectangle-area/main.go index 82853aa..68a4634 100644 --- a/06-variables/04-assignment/exercises/04-find-the-rectangle-area/main.go +++ b/06-variables/04-assignment/exercises/04-find-the-rectangle-area/main.go @@ -10,13 +10,13 @@ package main // --------------------------------------------------------- // EXERCISE: Find the Rectangle's Area // -// 1. Find the length of a rectangle +// 1. Find the area of a rectangle // Its width is 5 // Its height is 6 // -// 2. Assign the result to the `length` variable +// 2. Assign the result to the `area` variable // -// 3. Print the `length` variable +// 3. Print the `area` variable // // HINT // Rectangle formula = 2 * (width + height) @@ -29,7 +29,7 @@ func main() { // UNCOMMENT THE CODE BELOW: // var ( - // length int + // area int // width, height = 5, 6 // ) diff --git a/06-variables/04-assignment/exercises/04-find-the-rectangle-area/solution/main.go b/06-variables/04-assignment/exercises/04-find-the-rectangle-area/solution/main.go index dd931a7..86114dd 100644 --- a/06-variables/04-assignment/exercises/04-find-the-rectangle-area/solution/main.go +++ b/06-variables/04-assignment/exercises/04-find-the-rectangle-area/solution/main.go @@ -11,7 +11,7 @@ import "fmt" func main() { var ( - length int + area int width, height = 5, 6 ) @@ -20,7 +20,7 @@ func main() { // just like in math - length = 2 * (width + height) + area = 2 * (width + height) - fmt.Println(length) + fmt.Println(area) }