- Compiled language
- Runtime is baked into the final product => No VM required like Java
- Executables are exported at the compile time
- Executables are different for OS
- Where to expect Go
- System apps to web apps - cloud
- It is already in production
- Don't bring baggage of previous languages
- Object Oriented?
- Yes and No
- Object oriented language should have classes and objects, Go does'nt have classes (we have structs though)
- There is no Overriding/overloading in Go
- No try-catch
- lexer does a lot of work
- write
go mod init hello
in the terminal - write
go run main.go
in the terminal to run the file- This going to run the file, it will not give any executables.
- write
go help
in the terminal to get some help for Go - write
go env GOPATH
and explore other commands
-
- There is something called Lexer
- The job of the lexer is to make sure grammer of the language is being followed at pre-compile time
- If intellisense is installed, then Lexer will automatically kick in and put semicolons
- There is something called Lexer
-
- Case insensitive
- Define if public or private
- First letter defines if the thing is public or private
- Define if public or private
- Variable type should be known in advance
- Everything is a Type
- Case insensitive
-
- Memory allocation and deallocation happens automatically
- image
- Garbage collections happens automatically
- anything out of Scope or nil becomes eligible for garbage collection
-
- There is a problem that exist in all the programming languages, whenever variable, array etc are declared are just a reference of the memory. Values put inside these variables and constants, they get stored in some memory. Sometimes when passing these variables into functions, classes and objects, there is a problem that these variables actually not get passed along. A copy of the variable is created and that copy is passed into the functions. This creates some irregularities in the program. To avoid these irregularities, we have.... POINTERS.
- Pointers gives the surety that whatever the resource is being passed as a pointer. Instead of passing variables, passing memory address of these variables. It makes it 100% guaranteed that whatever is being passed is the actual value from the memory.
-
- Surprizingly arrays are used very less in golang
-
- Slices are powerful and most used datatype in golang
- Slices under the hood are arrays
- Arrays get some abstraction layer and some more features => Slices
-
- Key-value pair datatypes
-
- Alternate versions of classes
- we don't have classes in golang
- Alternate versions of classes
-
- Whenever a function executes, it executes line by line. As soon as defer is put, whatever is the next statement will be omitted and will be executed at the very end (before the function returns) of the function, in the reverse order they were deffered (LIFO)