Skip to content

Instantly share code, notes, and snippets.

@J7mbo
Last active December 29, 2019 12:19
Show Gist options
  • Save J7mbo/eba5646124a376dc9649272f85f373bb to your computer and use it in GitHub Desktop.
Save J7mbo/eba5646124a376dc9649272f85f373bb to your computer and use it in GitHub Desktop.
type Service struct {
Repository *UserRepository
}
func (s *Service) CountNumUsers() int {
if s == nil || s.Repository == nil {
return 0
}
return s.Repository.Count()
}
var s *Service
s.CountNumUsers() // 0, call on nil pointer allowed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment