Skip to content

Instantly share code, notes, and snippets.

@saiumesh535
Created October 15, 2019 17:05
Show Gist options
  • Save saiumesh535/f705947805076882beccb33e971f38db to your computer and use it in GitHub Desktop.
Save saiumesh535/f705947805076882beccb33e971f38db to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Http struct {
}
func (http *Http) Get(url string) string {
return fmt.Sprintf("the result from %s is nothing", url)
}
type NamesService struct {
Http *Http
}
func (service *NamesService) get_name_service(name string) string {
return fmt.Sprintf("name is %s and url is %s", name, service.Http.Get("http://loical"))
}
type GetNames struct {
Service NamesService
}
func (names *GetNames) get_name(name string) string {
return names.Service.get_name_service("umesh")
}
func main() {
http := &Http{};
service := NamesService{Http:http}
names := GetNames{Service:service}
fmt.Println("Hello!!", names.Service.get_name_service("umesh"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment