Skip to content

Enhance README, error handling, and tests for IPv6 functions#5

Open
praserx wants to merge 7 commits into
masterfrom
v130
Open

Enhance README, error handling, and tests for IPv6 functions#5
praserx wants to merge 7 commits into
masterfrom
v130

Conversation

@praserx
Copy link
Copy Markdown
Owner

@praserx praserx commented May 31, 2026

This pull request introduces several improvements and fixes to the ipconv library, focusing on error handling, performance optimizations, and compatibility updates. The changes enhance the reliability of IPv6 conversion functions, optimize memory usage, correct error messages, and update the project for newer Go versions. Tests and documentation have also been updated to reflect these improvements.

Core improvements and bug fixes:

  • Improved error handling in IPv6ToInt and IPv6ToBigInt to properly handle nil and invalid IP addresses, preventing possible panics. [1] [2] [3]
  • Fixed error messages for ErrNotIPv4Address and ErrNotIPv6Address (typo correction: "addres" → "address").
  • Updated IPv4ToInt to cache the result of To4() to avoid redundant computation.
  • Optimized IntToIPv6 to write directly to the target slice, reducing allocations.
  • Refactored BigIntToIPv6 to use big.Int.FillBytes for cleaner and more efficient conversion.

Go version and CI updates:

  • Updated the minimum Go version to 1.22 in go.mod and adjusted the GitHub Actions workflow to test against Go 1.21, 1.22, and 1.23. [1] [2]

Documentation and testing:

  • Fixed example code in README.md to compile and run correctly.
  • Added new tests for error handling in IPv6 conversion functions and introduced benchmarks for IntToIPv6 and BigIntToIPv6. [1] [2]
  • Updated the changelog for version 1.3.0 with a summary of these changes.

praserx added 2 commits May 31, 2026 21:45
… improve README examples and add benchmarks for IPv6 conversions
@praserx praserx self-assigned this May 31, 2026
@praserx praserx requested a review from Copilot May 31, 2026 19:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the ipconv Go library to improve conversion reliability (especially around IPv6 error handling), reduce allocations in hot paths, and refresh documentation/tests and Go/CI versioning.

Changes:

  • Harden IPv6 conversion functions against nil/invalid net.IP inputs and adjust error messages.
  • Reduce allocations in IntToIPv6 and simplify BigIntToIPv6 implementation.
  • Update README example, add error-path tests + benchmarks, and bump the module Go version / CI matrix.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Fixes the example to correctly branch on ParseIP success and avoid unused imports.
ipconv.go Updates error strings, improves IPv4/IPv6 conversions, and changes ParseIP’s version detection logic.
ipconv_test.go Adds IPv6 error-path tests and benchmarks for IPv6 conversion functions.
go.mod Bumps the module’s go directive to 1.22.
CHANGELOG.md Adds a v1.3.0 entry describing the changes.
.github/workflows/ipconv-test.yml Updates the Go version test matrix and normalizes step indentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ipconv.go
Comment thread ipconv.go
Comment thread ipconv.go
Comment thread .github/workflows/ipconv-test.yml
praserx and others added 3 commits May 31, 2026 22:05
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread README.md
Comment on lines +19 to 22
if err == nil && version == 4 {
val, _ := ipconv.IPv4ToInt(ip)
fmt.Println(val)
}
Comment thread ipconv.go Outdated
strategy:
matrix:
go-version: [1.18.x, 1.20.x, 1.22.x]
go-version: [1.22.x, 1.23.x]
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

3 participants