This repository has been archived on 2021-09-07. You can view files and clone it, but cannot push or open issues or pull requests.
2017-12-31 20:57:02 +03:00

25 lines
295 B
Go

package singleton
type Singleton interface {
AddOne() int
}
type singleton struct {
count int
}
var instance *singleton
func GetInstance() Singleton {
if instance == nil {
instance = new(singleton)
}
return instance
}
func (s *singleton) AddOne() int {
s.count++
return s.count
}