Created
January 27, 2023 10:04
-
-
Save arriqaaq/35e2b44a7e122901de09f846b64cdc48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"time" | |
) | |
var objectPool = sync.Pool{ | |
New: func() interface{} { | |
return time.Now() | |
}, | |
} | |
func main() { | |
// Get an object from the pool | |
t := objectPool.Get().(time.Time) | |
defer objectPool.Put(t) | |
// Use the object | |
_ = t.String() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment