fix(go): fix Go client to normalize request header keys using Header.Set

Merged
WU
3mo ago
+109-18

Use http.Header.Set when writing headerParams to http.Header in the generated Go client.

Previously, generated code directly assigned values to the underlying http.Header map:

headers[h] = []string{v}

This bypasses the header name canonicalization provided by http.Header.Set and may result in inconsistent header casing or duplicate logical headers.

This change replaces direct map assignment with:

headers.Set(h, v)

Changes

  • Use http.Header.Set when writing headerParams to http.Header.
  • Ensure request header names are canonicalized consistently.
  • Avoid inconsistent casing or duplicate logical headers caused by direct map assignment.
  • Add/update regression tests to cover the expected header handling behavior.

Related Issue

Fixes #24765

PR checklist


Summary by cubic

Normalizes request header keys in generated Go clients by using http.Header.Set instead of direct map assignment. This canonicalizes names and prevents duplicate logical headers.

  • If headerParams contains case-variant duplicates, only one canonical header is sent; which value is kept depends on map iteration order.
  • Regenerates Go samples and updates sample dependency snapshots (normalize go.mod Go versions to X.Y.0 and add missing go.sum entries like terraform-plugin-testing).