Skip to content

Conversation

@gitctrlx
Copy link
Contributor

@gitctrlx gitctrlx commented Sep 5, 2025

Add comprehensive query parameter methods that support url.Values and struct conversion:

Features Added:

  • SetQueryParamsFromValues: Direct configuration from url.Values map
  • SetQueryParamsFromStruct: Struct-to-query conversion using go-querystring

Implementation:

  • request.go: Added request-level methods with proper error handling
  • client.go: Added client-level SetCommon* variants for default parameters
  • request_wrapper.go: Added global wrapper functions for request methods
  • client_wrapper.go: Added global wrapper functions for client methods
  • go.mod: Added github.com/google/go-querystring dependency

Testing:

  • request_test.go: Comprehensive tests including slice handling
  • client_test.go: Client-level functionality tests

This PR implements the feature requested in #461.

Add comprehensive query parameter methods that support url.Values and struct conversion:

Features Added:
- SetQueryParamsFromValues: Direct configuration from url.Values map
- SetQueryParamsFromStruct: Struct-to-query conversion using go-querystring
- Support for complex data types including slices and nested structures
- Seamless integration with existing query parameter methods

Implementation:
- request.go: Added request-level methods with proper error handling
- client.go: Added client-level SetCommon* variants for default parameters
- request_wrapper.go: Added global wrapper functions for request methods
- client_wrapper.go: Added global wrapper functions for client methods
- go.mod: Added github.com/google/go-querystring dependency

Testing:
- request_test.go: Comprehensive tests including slice handling
- client_test.go: Client-level functionality tests
- Full test coverage for parameter merging and override behavior

API Consistency:
- Maintains three-tier architecture (request/client/global)
- Follows existing naming conventions and patterns
- Preserves backward compatibility with all existing methods

Use Cases:
- Direct url.Values integration for library interoperability
- Struct-based query parameters with url tags
- Simplified workflow for go-querystring users
- Enhanced developer experience with type-safe query building
@imroc imroc merged commit e62bc20 into imroc:master Sep 8, 2025
2 checks passed
@imroc
Copy link
Owner

imroc commented Sep 8, 2025

PR is perfect, I didn't find anything to improve, so I merged it.I will add the relevant usage to the official documentation

@imroc
Copy link
Owner

imroc commented Sep 8, 2025

Released in v3.55.0

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