diff --git a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs index c17a8b0044..ea026bd4c8 100644 --- a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs @@ -197,6 +197,10 @@ private void WriteFactoryMethodBodyForIntersectionModel(CodeMethod codeElement, } else if (propertyType.TypeDefinition is CodeClass || propertyType.TypeDefinition is CodeInterface || propertyType.TypeDefinition is CodeEnum) { + if (propertyType.TypeDefinition is CodeEnum) + { + propertyTypeImportName = conventions.GetTypeString(property.Type, parentClass, false, true); + } writer.StartBlock($"if {GetTypeAssertion(valueVarName, propertyTypeImportName, "cast", "ok")}; ok {{"); valueVarName = "cast"; }