I am getting a syntax error and I can't figure out why. I have tried several variations but no success.
type dataType int64
const (
PM_SENT dataType = iota + 1
PM_VIEWED
)
func messageHandler(m []byte) error {
var data map[string]interface{}
if err := json.Unmarshal(m, &data); err != nil {
return err
}
var dt dataType
flt, ok := data["type"].(float64); ok {
dt = dataType(flt)
}
return nil
}
I am getting this error:
.\messageHandler.go:23: syntax error: unexpected =, expecting comma or }
Even if I change to this I still get the same error:
var dt int64
flt, ok := data["type"].(float64)
if ok {
dt = int64(flt)
}