Go(golang) Tutorials - Concepts and Conventions

Published: 10 March 2018
on channel: Ambasoft Java
604
10

#golang #go #fundamentals

Conventions
1.Comments
1. Single line comments as in C++ "//"
2. Multi-line comments as in C "/* */"
3. Multi-line comment to the top of the package represents a GoDoc
2.Imports
1. All the package names will start with lower case letters - "fmt"
2. Package names may have subdirectory path for name resolution - "encoding/json"
3. Packages once imported must be used in the code. - No unused imports allowed
3. Curly Braces
1. Curly Braces should be defined in-line and should not be in a new line - "func main() {"
2. Even a single line after an if-statement or for-statement mandates curly braces - You can't omit curly brace at any cost
3.Parantheses
1. Parantheses for conditions in if block are not mandatory
4.Short declaration form - declaration and assignment
Example a:=10
":=" This is a short declaration form which informs the go compiler to declare and assign value to a variable
The data type for the variable declared in the left side of the operator will be inferred by the data type of the value assigned in the left
In the above example, the data type of variable "a" will be identified by the data type of the value "10". As it is a numeric value, go compiler will consider "a" as an int variable
This is one of the smart operations introduces in Golang
5.Semicolon - Semi colons or not mandatory to terminate a line - it is better to ignore them for every statement, compiler will add it for you

Next Video :- Literals, Identifiers, Statements and more


Watch video Go(golang) Tutorials - Concepts and Conventions online, duration hours minute second in high quality that is uploaded to the channel Ambasoft Java 10 March 2018. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 604 times and liked it 10 visitors.