Factory Method Pattern In Golang

Member

letha

by letha , in category: Golang , 2 months ago

Factory Method Pattern In Golang 😁

1
2
3
4
5
6
7
8
9
func getTransport(tt string) (iTransport, error) {
	if tt == "scooter" {
		return newElectricScooter(), nil
	}
	if tt == "quadcopter" {
		return newQuadcopter(), nil
	}
	return nil, fmt.Errorf("Wrong type")
}


Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers