#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
Смотрите видео Go(golang) Tutorials - Concepts and Conventions онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Ambasoft Java 10 Март 2018. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 604 раз и оно понравилось 10 посетителям.