Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Created January 27, 2023 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arriqaaq/35e2b44a7e122901de09f846b64cdc48 to your computer and use it in GitHub Desktop.
Save arriqaaq/35e2b44a7e122901de09f846b64cdc48 to your computer and use it in GitHub Desktop.
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