Go - Dependancy Injection pattern.
Dependancy injection is a pattern where we pass down dependancies to initializers. This pattern is used to avoid global variables and to make code more testable. For example in go, you can create a service which depends on a repository and pass the repository to the service initializer. Suppose you have a directory like this server ├─entities │ ├─data.go │ └─server.go ├─handler │ └─handler.go ├─service │ └─service.go └─storage └─storage.go main.go suppose you have a User struct in data.go ...