Skip to content

feat(go): implement TCP/TLS connection in Go SDK#2834

Open
saie-ch wants to merge 2 commits intoapache:masterfrom
saie-ch:feature/go_tcp_tls
Open

feat(go): implement TCP/TLS connection in Go SDK#2834
saie-ch wants to merge 2 commits intoapache:masterfrom
saie-ch:feature/go_tcp_tls

Conversation

@saie-ch
Copy link

@saie-ch saie-ch commented Feb 27, 2026

Which issue does this PR close?

This unblocks issue #2807 so TCP/TLS integration tests and examples can now be written for the Go
SDK.

Rationale

The Go SDK had TLS configuration fields (tlsEnabled, tlsDomain, tlsCAFile, tlsValidateCertificate)
and TLS error types generated, but the handshake was stubbed out at line 329 with return
errors.New("TLS connection is not implemented yet"). This blocked writing integration tests and
examples for TCP/TLS connections.

What changed?

Before: Line 329 returned a stub error preventing any TLS connections.

After: Full TLS implementation with:

  • Added 4 TLS configuration option functions: WithTLS(), ### WithTLSDomain(), WithTLSCAFile(),
    WithTLSValidateCertificate()
  • Implemented createTLSConfig() helper method that:
    • Configures certificate validation (InsecureSkipVerify)
    • Extracts server name from address for SNI (if tlsDomain not provided)
    • Loads custom CA certificates from file
    • Returns appropriate TLS error types (ErrInvalidTlsDomain, ErrInvalidTlsCertificatePath,
      ErrInvalidTlsCertificate)
  • Replaced stub with actual TLS handshake using crypto/tls (lines 360-373):
    • Creates TLS config
    • Wraps TCP connection with tls.Client()
    • Performs TLS handshake with proper error handling

Implementation follows the same patterns as Rust (tcp_tls_connection_stream.rs), Java
(InternalTcpClient.java), C# (TcpMessageStream.cs), and Node.js (client.connection.ts) SDKs.

AI Usage

Claude Sonnet 4.5

  • Guided by existing Rust, Java, Node.js, and C# TLS implementations
  • Followed Go SDK patterns and used existing error types
  • All pre-merge checks passed locally

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 0% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.55%. Comparing base (3432714) to head (aae02e2).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
foreign/go/client/tcp/tcp_core.go 0.00% 42 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2834      +/-   ##
============================================
- Coverage     67.58%   67.55%   -0.04%     
  Complexity      708      708              
============================================
  Files          1027     1027              
  Lines         83147    83188      +41     
  Branches      60004    60004              
============================================
  Hits          56195    56195              
- Misses        24612    24653      +41     
  Partials       2340     2340              
Flag Coverage Δ
go 6.77% <0.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
foreign/go/client/tcp/tcp_core.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@hubcio hubcio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants