I am new to golang and switched from python to golang. How can I convert this if else statement in a "switch"
type Client struct {
Type string `json:"type"`
}
Then I am initializing this struct like this:
a:= Client{"v1"}
if a.Type == "v1" {
if err := apiClient.v1("I am version one"); err != nil {
log.Printf(" Error: Sending type v1")
return err
}
} else if a.Type == "v2" {
if err := apiClient.v2("I am version 2"); err != nil {
log.Printf(" Error: Sending type v2
")
return err
}
} else {
return errors.New(fmt.Sprintf(" Error: Invalid mertype...This Type"))
}