HF-Intro Flashcards
Go file structure ?
Package declaration
Import statement
<rest>
</rest>
Do we need “semicolon” to end statements in Go-Lang?
No
Can we format the Go-code into a good looking form?
gofmt
What is “fmt.Println()”?
- 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 sharing of code from one package to another package works ?
This is done by “import” statement. Once imported, all functions belongs to a particular package can be used inside the other package.
Can we combine multiple import statement….as generally we will have more than one import statement ?
Yes, Just take out the common keyword “import” and provide every import in a new line:
»> import (
»> “fmt”
»> “strings”
»> “math”
»> )
Casing convention for “package” and Functions” ?
- All package names must be starting with “lower-case” letter
- All Function names must be starting with “upper-case” letter
How Strings are represented in Go and how can we include Newline, Tab, double quote and backward slash?
- Strings are represented by “double quote” only
- New line - “\n”
- Tab - “\n”
- Double quote - “\””
- Backward slash - “\”
How characters are represented in Go-lang? What are runes?
In go-lang, character values are represented in single quote ‘A’, ‘B’, ‘C’.
These character values are also known as “runes”.