Tips That You Should Know Before Start Writing on GO!

Not even in 1 day, but in 1 sitting.Fast language — in view of the compiled nature and limited syntax, it will be difficult for you to survive a lot of memory and CPU time in your programs.Strong typing is very nice when the IDE at any time knows the type of the variable and the transition through the code works like a clock..This is not an advantage of Go, but it also has it.Protection against expanding structures — OOP in Go is emulated by structures and methods for structures, but the rule is that it should be in the same file..And this is very good in terms of analyzing someone else’s code, Ruby has a mixing pattern and sometimes the devil breaks a leg.Delayed deinitialization..An example is best illustrated:package mainimport ( "fmt" "os" "log")func main() { file, err := os.Open("file.txt") if err != nil { log.Fatal(err) } defer file.Close()b, err := ioutil.ReadAll(file) fmt.Print(b)}Thanks to:defer file.Close()It immediately informs runtime that, regardless of how and where the exit from the function will be, in the end, it is necessary to execute certain code..This immediately partially solves the problem with the absence of destructors and almost completely solves the problem of missing contexts (for example, Python with).Why did it happenGo looks like a superset of C..A lot says about it: the syntax is similar and the understanding of how this can be easily converted into C code..Of course, gorutin, garbage collection and interfaces (and with it RTTI) are atypical for C, but the rest of the code is easily converted almost by regulars.And this nature, in my opinion, and dictates almost all the above strangeness.SummaryGo is great for quick writing of low-cost and fast microservices, while any experienced developers from other languages ​​are suitable for this work..It is in this matter that he has few equals.Go young As it was rightly noted by one of the commentators: “The idea for 5, the implementation for 3”..Yes, as a universal language — by three, but purely for microservices by 4..Plus, the language develops, it is quite possible to correct half of the described shortcomings and it will become significantly better.The first month of work you will struggle with the compiler..Then you will understand his character and the struggle will pass..But this month will have to go through.. More details

Leave a Reply