1. In Go we have multiple packages. If the package is main it must have a main function as well and it’s a executable package where as if there is any other name it will be the reuseable package.
2. We can do go run, go build and many others like go fmt (format code), test , install, get etc.
3. Multiple files with same package name will be considered as that one package one can have multiple files all starting with package main
4. We can use all the inbuilt packages or the packages created by the common people.
5. A function can have multiple return values.
6. using the os.WriteFile and ReadFile function we can write in to the file as a [] byte and its a ascii form of the string and get it back the same way. It is not able to read we can also the error handling for the same.
7. At the same place we can provide the error handling options as well. like the exit codes and the status of the exit code can be non zero for handling the errors and thus can be made sure that its working as expected.
8. The os.exit () fuction is supposed to get the status code 0 only for the pass in case of failed its expected to give the status code of 1-n
9. No inbuilt package to shuffle the deck.
10. Go does not proivide data like the 10 test cases were executed it just gives the name that the test case passed it only assumes that something terriblke is not failing inside our function.
STRUCTS
Its kind of a dictionary in python and its there for the golang to make sure we can add a dataset that has like 2 strings related.
so we have a struct that can have a person's name first name and last name both strings and that is a struct.
If the variable is defined but no value defined it automatically deifnes the zero values like string has "" int has 0 etc.
A struct can also have a struct inside embedding of struct is allowed and its helpful to make a very detailed and complex data types
GO is a PASS BY VALUE language the RAM is seprately allocated and is copied in case of allocation to another variable.
MAPS in Golang
In maps both keys and values are static. The keys should be of one type and the values should be of one type. they both can be different like keys as string and values as int but 2 values has to be same.
In maps the string can always be accessed through [] not by . like map.value as it might be int
MAPS vs SRUCT
INTERFACES
Interface is the common ground for functions that are similar but receiver functions of different type Interface is making a third type that accepts both differnt types and hence can be used to define and call a common function
- interfaces are not generic types.
- interfaces are implicit declare and use. not defining any link between any.
- interfaces are just contracts if the internal functions break interface can't do anything really.
- interface is tough and can be used the ideal ones from the library not required just for the code quality.
- Multiple interfaces can assemble to make a single interface.
IMPORTANT NOTES
%v is used to print the value of the arguments %T is used to print the type of the arguments
The switch statement in Go is similar to the ones in C, C++, Java, JavaScript, and PHP. The difference is that it only runs the matched case so it does not need a break statement.
It can also have multiple caees like case 1,3 6 : like that multiple match cases
Possible go questions
- what is a receiver function?
- what is the difference between the concrete types and interface

