News for hackers. Stuff that matters.
Re:Singleton Pattern in Go by vortico on Sunday July 12, 2015 @03:02PM (#9874494)
What's the point of a singleton when you can just have variables in an anonymous struct at root level, and functions defined at root as well?

  var server struct {
  	host string
  	port string
  }
  
  func serverStart() {
  	server.host = "..."
  	server.port = "..."
  }
Re:Singleton Pattern in Go by pcwalton on Sunday July 12, 2015 @03:35PM (#9874609)
When do you call "serverStart()"? If the answer is "eagerly during startup", there's no problem (other than startup time, of course). If the answer is "on demand", now you have a synchronization problem.
Re:Singleton Pattern in Go by btzll on Sunday July 12, 2015 @03:35PM (#9874611)
Because there are many ways to solve a problem.