50 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2019-05-03 17:29:16 +03:00
## What is the difference between `go build` and `go run`?
2018-10-13 23:30:21 +03:00
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*
2018-10-19 20:31:10 +03:00
> **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.
>
>
2018-10-13 23:30:21 +03:00
2019-05-03 17:29:16 +03:00
## Go saves the compiled code in a directory. What is the name of that directory?
2018-10-13 23:30:21 +03:00
1. The same directory where you call `go build` *CORRECT*
2. $GOPATH/src directory
3. $GOPATH/pkg directory
4. Into a temporary directory.
2018-10-19 20:31:10 +03:00
> **2:** There only lives Go source-code files
>
>
> **3:** Go only puts your code there when you call `go install`.
>
>
2018-10-13 23:30:21 +03:00
2019-05-03 17:29:16 +03:00
## Which is true for runtime?
2018-11-18 05:03:43 +08:00
1. It happens when your program starts running on a computer *CORRECT*
2018-10-13 23:30:21 +03:00
2. It happens while your program is being compiled
2019-05-03 17:29:16 +03:00
## Which is true for the compile-time?
2018-11-18 05:03:43 +08:00
1. It happens when your program starts running on a computer
2018-10-13 23:30:21 +03:00
2. It happens while your program is being compiled *CORRECT*
2019-05-03 17:29:16 +03:00
## When can a Go program print a message to the console?
2018-10-13 23:30:21 +03:00
1. While it's being compiled.
2. While it runs (after compile-time). *CORRECT*
3. While it runs (inside the compile-time).
2018-10-19 20:31:10 +03:00
> **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
>
2019-05-03 17:29:16 +03:00
>