asdf
This commit is contained in:
parent
83bbe32525
commit
1072400433
|
|
@ -13,4 +13,7 @@ func main() {
|
|||
f := square()
|
||||
fmt.Println(f())
|
||||
fmt.Println(f())
|
||||
fmt.Println(f())
|
||||
fmt.Println(f())
|
||||
fmt.Println(f())
|
||||
}
|
||||
|
|
@ -1 +1,24 @@
|
|||
package defer
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func logger(s string) func() {
|
||||
fmt.Printf("Enter in %s\n",s)
|
||||
now := time.Now()
|
||||
return func () {
|
||||
fmt.Printf("Time elapsed %s\n",time.Since(now))
|
||||
fmt.Printf("Exit from func %s\n",s)
|
||||
}
|
||||
}
|
||||
|
||||
func SlowOP() {
|
||||
defer logger("SlowOP")()
|
||||
time.Sleep(2*time.Second)
|
||||
}
|
||||
|
||||
func main() {
|
||||
SlowOP()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user