- Golang does not contains class, It only have packages.
- golang feels us more connectivity with OS.
- There is no need of defining datatypes, The compiler is smart enough to determin the datatype automatically. And also at automatically remove semicolons.
- When we save the file it comppiles and check the syntex.
before : var person ="Rio"
after: person := "Rio"
summary: var person ="Rio" == person :="Rio"
If we assign any variable starting with capital letter (Person), It can directly export to another file but cannot eccess outside if assign with small starting letter(Person). Same is APPLICABLE FOR FUNCTIONS ALSO.
%s -> string, %d -> int , %.3f -> float eg: fmt.Printf("Name is %s age is %d Height is %.3f", name, age, height)
The curly braces will starts where function is declared not from the next line. eg,
- correct: func main(){
}
- wrong: func main() {
}
- Array ->static
- Slices -> dynamic (It's like vector)
declaration :
Array :
- var name[5] string
- var name =[5] int{1,2,3,4,5}
Slices :
- numbers :=[] int {1,2,3} It has length,capacity, Pointer.
- unordered
- Dynamic
- Key and values
- Initialization
- In go, The time format is fixed. i.e, 2006-01-02 15:04:05
- YYYY-MM-DD hh:mm:ss
- Gorutine follows concurrency and parrallism.