fix: massive questions markdown fix
This commit is contained in:
@@ -10,10 +10,18 @@ func main() {
|
||||
3. fmt.Println
|
||||
4. import
|
||||
|
||||
> 1. This keyword is used to declare a new function.
|
||||
> 2. That's right! package keyword allows you to define which package a Go file belongs to.
|
||||
> 3. This is not a keyword. It's the Println function of the fmt package.
|
||||
> 4. This keyword is used to import a package.
|
||||
> **1:** This keyword is used to declare a new function.
|
||||
>
|
||||
>
|
||||
> **2:** That's right! package keyword allows you to define which package a Go file belongs to.
|
||||
>
|
||||
>
|
||||
> **3:** This is not a keyword. It's the Println function of the fmt package.
|
||||
>
|
||||
>
|
||||
> **4:** This keyword is used to import a package.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## Which keyword is used to declare a new function?
|
||||
@@ -29,16 +37,24 @@ func main() {
|
||||
3. It allows Go to import a package called function.
|
||||
4. It prints a message to the console.
|
||||
|
||||
> 2. Go looks for package main and func main to do that. A function doesn't do that on its own.
|
||||
> 3. `import` keyword does that.
|
||||
> 4. For example: `fmt.Println` does that.
|
||||
> **2:** Go looks for package main and func main to do that. A function doesn't do that on its own.
|
||||
>
|
||||
>
|
||||
> **3:** `import` keyword does that.
|
||||
>
|
||||
>
|
||||
> **4:** For example: `fmt.Println` does that.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## Do you have to call the main function yourself?
|
||||
1. Yes, so that, I can execute my program.
|
||||
2. No, Go calls the main function automatically. *CORRECT*
|
||||
|
||||
> 1. No, you don't need to call the main function. Go automatically executes it.
|
||||
> **1:** No, you don't need to call the main function. Go automatically executes it.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## Do you have to call the other functions yourself?
|
||||
@@ -46,11 +62,17 @@ func main() {
|
||||
2. Yes, so that, Go can execute my program.
|
||||
3. No, Go calls the functions automatically.
|
||||
|
||||
> 1. That's right. You need to call a function yourself. Go won't execute it automatically. Go only calls the main function automatically (and some other functions which you didn't learn about yet).
|
||||
> **1:** That's right. You need to call a function yourself. Go won't execute it automatically. Go only calls the main function automatically (and some other functions which you didn't learn about yet).
|
||||
>
|
||||
>
|
||||
|
||||
> 2. That's only the job of the `func main`. There's only one `func main`.
|
||||
> **2:** That's only the job of the `func main`. There's only one `func main`.
|
||||
>
|
||||
>
|
||||
|
||||
> 3. Go doesn't call any function automatically except the main func (and some other functions which you didn't learn about yet). So, except the main func, you need to call the functions yourself.
|
||||
> **3:** Go doesn't call any function automatically except the main func (and some other functions which you didn't learn about yet). So, except the main func, you need to call the functions yourself.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## What does `package main` do?
|
||||
@@ -76,9 +98,15 @@ func main() {
|
||||
2. Go starts executing your program by using the code inside func main *CORRECT*
|
||||
3. It prints a message to the console
|
||||
|
||||
> 1. main function doesn't contain a package.
|
||||
> 2. That's right. Go automatically calls the main function to execute your program.
|
||||
> 3. It doesn't print anything at least directly.
|
||||
> **1:** main function doesn't contain a package.
|
||||
>
|
||||
>
|
||||
> **2:** That's right. Go automatically calls the main function to execute your program.
|
||||
>
|
||||
>
|
||||
> **3:** It doesn't print anything at least directly.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## What does `import "fmt"` do?
|
||||
@@ -94,9 +122,15 @@ func main() {
|
||||
2. It defines a new package called "fmt"
|
||||
3. It imports the `fmt` package; so you can use its functionalities *CORRECT*
|
||||
|
||||
> 1. `fmt.Println` prints a message not the `import "fmt"`.
|
||||
> 2. `package` keyword does that, not the `import` keyword.
|
||||
> 3. Yes. For example, after you import the fmt package you can call its Println function to print a message to the console.
|
||||
> **1:** `fmt.Println` prints a message not the `import "fmt"`.
|
||||
>
|
||||
>
|
||||
> **2:** `package` keyword does that, not the `import` keyword.
|
||||
>
|
||||
>
|
||||
> **3:** Yes. For example, after you import the fmt package you can call its Println function to print a message to the console.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## What this program does?
|
||||
@@ -110,11 +144,17 @@ func main() {
|
||||
2. It's a correct program but it doesn't print anything *CORRECT*
|
||||
3. It's an incorrect program
|
||||
|
||||
> 1. It doesn't print a message. To do that you can use fmt.Println function.
|
||||
> **1:** It doesn't print a message. To do that you can use fmt.Println function.
|
||||
>
|
||||
>
|
||||
|
||||
> 2. Yes, it's a correct program but since it doesn't contain fmt.Println it doesn't print anything.
|
||||
> **2:** Yes, it's a correct program but since it doesn't contain fmt.Println it doesn't print anything.
|
||||
>
|
||||
>
|
||||
|
||||
> 3. It's a correct program. It uses the package keyword and it has a main function. So, this is a valid and an executable Go program.
|
||||
> **3:** It's a correct program. It uses the package keyword and it has a main function. So, this is a valid and an executable Go program.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## What does this program print?
|
||||
@@ -129,9 +169,13 @@ func main() {
|
||||
* It doesn't print anything
|
||||
* This program is incorrect *CORRECT*
|
||||
|
||||
> 1. It doesn't pass the message to Println wrapped between double-quotes. It should be like: fmt.Println("Hi! I want to be a Gopher")
|
||||
> **1:** It doesn't pass the message to Println wrapped between double-quotes. It should be like: fmt.Println("Hi! I want to be a Gopher")
|
||||
>
|
||||
>
|
||||
|
||||
> 3. It doesn't import "fmt" package. Also see #1.
|
||||
> **3:** It doesn't import "fmt" package. Also see #1.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## What does this program print?
|
||||
@@ -147,5 +191,9 @@ func main() {
|
||||
* fmt
|
||||
* This program is incorrect; it imports the wrong package or there isn't a function called `Println`
|
||||
|
||||
> 2. import "fmt" imports the `fmt` package; so you can use its functionalities.
|
||||
> 3. Actually, this program is correct.
|
||||
> **2:** import "fmt" imports the `fmt` package; so you can use its functionalities.
|
||||
>
|
||||
>
|
||||
> **3:** Actually, this program is correct.
|
||||
>
|
||||
>
|
@@ -2,8 +2,12 @@
|
||||
1. `go run` just compiles a program; whereas `go build` both compiles and runs it.
|
||||
2. `go run` both compiles and runs a program; whereas `go build` just compiles it. *CORRECT*
|
||||
|
||||
> 1. It's opposite actually.
|
||||
> 2. `go run` compiles your program and puts it in a temporary directory. Then it runs the compiled program in there.
|
||||
> **1:** It's opposite actually.
|
||||
>
|
||||
>
|
||||
> **2:** `go run` compiles your program and puts it in a temporary directory. Then it runs the compiled program in there.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## Which directory `go build` puts the compiled code into?
|
||||
@@ -12,8 +16,12 @@
|
||||
3. $GOPATH/pkg directory
|
||||
4. Into a temporary directory.
|
||||
|
||||
> 2. There only lives Go source-code files
|
||||
> 3. Go only puts your code there when you call `go install`.
|
||||
> **2:** There only lives Go source-code files
|
||||
>
|
||||
>
|
||||
> **3:** Go only puts your code there when you call `go install`.
|
||||
>
|
||||
>
|
||||
|
||||
|
||||
## Which directory `go run` puts the compiled code into?
|
||||
@@ -38,6 +46,12 @@
|
||||
2. While it runs (after compile-time). *CORRECT*
|
||||
3. While it runs (inside the compile-time).
|
||||
|
||||
> 1. In the compilation step your program cannot print a message. In that stage, it's literally dead.
|
||||
> 2. That's right. That's the only time which your program can interact with a computer and instruct it to print a message to the console.
|
||||
> 3. Running can only happen after the compile-time
|
||||
> **1:** In the compilation step your program cannot print a message. In that stage, it's literally dead.
|
||||
>
|
||||
>
|
||||
> **2:** That's right. That's the only time which your program can interact with a computer and instruct it to print a message to the console.
|
||||
>
|
||||
>
|
||||
> **3:** Running can only happen after the compile-time
|
||||
>
|
||||
>
|
Reference in New Issue
Block a user