Tags: gotmc/lxi
Tags
Preserve underlying I/O error when returning context errors Previously, when both an I/O error and a context error occurred, only the context error was returned, discarding useful diagnostic information. Now wraps both errors using multi-%w so callers can still match on context.DeadlineExceeded or context.Canceled while also inspecting the underlying network error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace ReadContext/WriteContext with ReadBinary/WriteBinary Implement the ivi.Transport interface by replacing ReadContext and WriteContext with ReadBinary and WriteBinary. Make ReadStringContext and WriteStringContext unexported (readString) or inlined since they are internal implementation details. Command and Query use the new methods internally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Return context errors instead of raw network timeouts on cancellation When context cancellation triggers a connection deadline, the I/O methods now check ctx.Err() and return the context error (e.g., context.Canceled, context.DeadlineExceeded) instead of the raw network timeout. This follows the net.Dialer.DialContext pattern and lets callers use errors.Is() for context-related failures. Also updates CLAUDE.md to reflect recent API additions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add ReadStringContext and WriteStringContext context-aware methods Command and Query now delegate to WriteStringContext and ReadStringContext respectively, eliminating redundant applyContext calls that previously occurred when these methods called non-context helpers that internally called context-aware methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add accessor methods and change boardIndex/port to int Add getter methods for all VisaResource fields to allow external consumers programmatic access while keeping fields unexported for immutability. Change boardIndex and port from uint to int for idiomatic Go usage. Update tests to use the new accessors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use len(a) > 0 for variadic check and fix misplaced doc comment Check variadic args with len(a) > 0 instead of a != nil so that spreading an empty slice works correctly. Also move the NewVisaResource doc comment to directly above the function signature. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add comprehensive tests and fix data race in applyContext Expand visa_test.go with error and edge cases (invalid interface type, invalid resource class, empty string, missing fields, lowercase input, hostname). Add lxi_test.go with tests for Device methods (Command, Query, WriteString, Read, Write, Close) and all applyContext code paths using net.Pipe. Fix data race in applyContext by capturing d.conn before launching the cancellation goroutine. Coverage increased from 30.3% to 93.5%. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add context.Context to NewDevice and fix goroutine leak in applyContext NewDevice now accepts a context.Context and uses net.Dialer.DialContext, allowing callers to cancel or timeout the initial TCP connection. The applyContext helper now returns a cleanup function that stops its cancellation-watching goroutine when the I/O operation completes, preventing leaks with long-lived contexts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PreviousNext