learning_go/patterns/simpleFactory/gunFactory.go
2025-12-15 20:20:11 +03:00

13 lines
218 B
Go

package main
import "errors"
func GetGun(gunType string) (IGun,error){
if gunType == "ak47" {
return newAk47(),nil
}
if gunType == "musket" {
return newMusket(),nil
}
return nil,errors.New("No such a gun")
}