packages
-Every package file has to start with package. Importing
-Both are the same Control Loops
- No paranthesis required around conditionals and increments - Variable Initialization and Increment is optional here Maps
|
Variable Types
Variable Conversion
you can replace float32 with different types Array
Pointers
If-else & Switch Case
-Variables declared inside an if short statement are only in scope until the end of if-else block -Go's switch cases need not be constants, and the values involved need not be integers |
Variables basic
":=" is called Short Assignment statement Outside of function ":=" is not allowed Exported names :- To use any variable outside of package it must start with Capital Letter or else it will not run Slices
- An array has a fixed size. A slice, on the other hand, is a dynamically-sized, flexible view into the elements of an array - A slice does not store any data, it just describes a section of an underlying array Functions
- func is used to declaration function - in case of different input type we have to specify each one differently - Output type is must if there is single return then no need to add paranthesis Structs
-A struct is a collection of fields -A struct literal denotes a newly allocated struct value by listing the values of its fields |
Cheatography
https://cheatography.com
Go Lang Cheat Sheet (DRAFT) by Navron
Go Command for instant Learning Basics
This is a draft cheat sheet. It is a work in progress and is not finished yet.