This is a very annoying problem, and one that we hit a lot in my project (
https://github.com/deepmap/oapi-codegen), where we generate Go models from OpenAPI specs, and the OpenAPI "AnyOf" or "OneOf" schema does precisely this.
You can partially unmarshal; store your "type" field in a typed variable, and use json.RawMessage to defer parsing to later, when you know the type. This still gets annoying, because if your field names are dynamic, you need to override the default unmarshaling behavior to produce a map of field names to json.RawMessage. If you jump through these hoops, you can avoid parsing twice. Once you've partially parsed your object, you can create some functions on it, such as "AsAtype()" or "AsBType()", which switches on "type" and returns the correct concrete object.