Created
August 20, 2021 06:10
-
-
Save percybolmer/ebda0612ef6b344da0fae8b326ad77d7 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
| "NewService": { | |
| "scope": "go", | |
| "prefix": "NewService", | |
| "body": [ | |
| "// Configuration is a alias for a function that takes a Service pointer and modifies it", | |
| "type Configuration func(s *Service) error", | |
| "", | |
| "// Service is a struct that holds all repositories and combines logic", | |
| "type Service struct {", | |
| " //Add Repository fields here", | |
| "}", | |
| "", | |
| "// New$1Service creates a new Service and accepts a variable amount of config functions", | |
| "func New$1Service(configuration ...Configuration) *Service {", | |
| " s := &Service{}", | |
| " for _, cfg := range configuration{", | |
| " if err := cfg(s); err != nil {", | |
| " panic(err)", | |
| " }", | |
| " }", | |
| " return s", | |
| "}", | |
| ], | |
| "description": "Creates a new Service with a Constructor function" | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment