HF-Intro Flashcards

1
Q

Go file structure ?

A

Package declaration
Import statement

<rest>
</rest>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Do we need “semicolon” to end statements in Go-Lang?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Can we format the Go-code into a good looking form?

A

gofmt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is “fmt.Println()”?

A
  • Provided by “fmt” package // “fmt” means “format”
  • Prints/outputs message to terminal
    Can be used with single or multiple arguments
  • If multiple arguments are provided, then they all be printed with “space”
  • Provide a “line” at the end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How sharing of code from one package to another package works ?

A

This is done by “import” statement. Once imported, all functions belongs to a particular package can be used inside the other package.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can we combine multiple import statement….as generally we will have more than one import statement ?

A

Yes, Just take out the common keyword “import” and provide every import in a new line:
»> import (
»> “fmt”
»> “strings”
»> “math”
»> )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Casing convention for “package” and Functions” ?

A
  • All package names must be starting with “lower-case” letter
  • All Function names must be starting with “upper-case” letter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How Strings are represented in Go and how can we include Newline, Tab, double quote and backward slash?

A
  • Strings are represented by “double quote” only
  • New line - “\n”
  • Tab - “\n”
  • Double quote - “\””
  • Backward slash - “\”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How characters are represented in Go-lang? What are runes?

A

In go-lang, character values are represented in single quote ‘A’, ‘B’, ‘C’.
These character values are also known as “runes”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly