Repository: microsoft/kiota (csharp)

Issue:
Passing `contentType` by reference instead of by Value for Go StreamContent
The func `requestInfo.SetStreamContentAndContentType`  in Go expects the content type string to be passed by value and not by reference https://github.com/microsoft/kiota-abstractions-go/blob/920cc73050b562c875f3c7a88ba93197e52dbe68/request_information.go#L232C36-L232C58

The var `contentType` should be cast to pass by val

Pull request description:
Fixes https://github.com/microsoft/kiota/issues/3830

Passes "requestContent" param by val instead of by ref.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a60618dde4..9b8ec88e76 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Removed reflection for Java enum deserialization. [microsoft/kiota-java#843](https://github.com/microsoft/kiota-java/pull/843)
 - Added support for AnyOf arrays. [#3786](https://github.com/microsoft/kiota/pull/3792)
 - Fixed a bug where property names that matched reserved type would be replaced in dotnet.
+- Fixed pass by value for `contentType` param in Go `requestInfo.SetStreamContentAndContentType`[#3830](https://github.com/microsoft/kiota/issues/3830)
 
 ## [1.8.2] - 2023-11-08
 
diff --git a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs
index 4a77dd238a..a8e55d6e50 100644
--- a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs
+++ b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs
@@ -867,7 +867,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req
             if (requestParams.requestBody.Type.Name.Equals("binary", StringComparison.OrdinalIgnoreCase) || requestParams.requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase))
             {
                 if (requestParams.requestContentType is not null)
-                    writer.WriteLine($"{RequestInfoVarName}.SetStreamContentAndContentType({bodyParamReference}, {requestParams.requestContentType.Name.ToFirstCharacterLowerCase()})");
+                    writer.WriteLine($"{RequestInfoVarName}.SetStreamContentAndContentType({bodyParamReference}, *{requestParams.requestContentType.Name.ToFirstCharacterLowerCase()})");
                 else if (!string.IsNullOrEmpty(codeElement.RequestBodyContentType))
                     writer.WriteLine($"{RequestInfoVarName}.SetStreamContentAndContentType({bodyParamReference}, \"{codeElement.RequestBodyContentType}\")");
             }


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs
index c6b5653d9c..31a40e7a56 100644
--- a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs
+++ b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs
@@ -1327,7 +1327,7 @@ public void WritesRequestGeneratorBodyUnknownRequestBodyType()
         var result = tw.ToString();
         Assert.Contains("SetStreamContentAndContentType", result, StringComparison.OrdinalIgnoreCase);
         Assert.DoesNotContain("application/json", result, StringComparison.OrdinalIgnoreCase);
-        Assert.Contains(", requestContentType", result, StringComparison.OrdinalIgnoreCase);
+        Assert.Contains(", *requestContentType", result, StringComparison.OrdinalIgnoreCase);
         AssertExtensions.CurlyBracesAreClosed(result);
     }
     [Fact]