Internet more than 20 years, has reached the crossroads. Before the advent of the blockchain, the internet was known as the classical Internet, and the use of blockchain technology in the Internet only entered the post-Internet era. As a new technology, the blockchain is undoubtedly on the cusp, and its development prospects for the general public will eventually be positive. But at present, because the blockchain technology is in the early stage of development, there are some problems, such as technology maturity and limited application scenario, the Brother Education advises users to carefully consider and discern before choosing professional Go Language + blockchain training institution.
Execution of defer in Golang
Everyone knows Golang's defer keyword, which can perform some operations before the function is returned, most commonly used to open a resource (such as a file, database connection, etc.) and use defer delay to turn off the resource to avoid a memory leak. For example:
Func do () (ok bool) {
File,_: = os. Open ("C:\a.txt")
Defer file. Close ()
DoSomething
return OK
}
We can see in the official document that the order of execution of defer is in reverse order, that is, the advanced sequence:
For I: = 0; I < 5; i++ {
Defer FMT. Printf ("%d", i)
}
The print result is: 4,3,2,1,0
Then look at this example:
Func Deferret (x, y int) (z int) {
Defer z + = 100
z = x + y
Return z + 50//execution Order z = z+50 (call defer) Z = z+100, ret
}
Func Main () {
I: = Deferret (+)
println (i)//print 152
}
high-energy early warning, brother even education blockchain live course August continues to hit the hot!
The original price of 1188 Yuan of 12 block chain advanced courses, now only need 1 Yuan!
Also can receive free "Go Language foundation actual combat project development" and "Go language Advanced Combat Project development" textbook Two!! Limited time limit!! First come first served!!
Http://www.ydma.cn/open/course/24
Follow brother Lian Blockchain technology public number get more technical dry Goods Oh!!!