Skip to content

FEATURE: add method call based default valuer#29

Merged
c9s merged 3 commits intomainfrom
feature/support-default-method-valuer
Aug 22, 2025
Merged

FEATURE: add method call based default valuer#29
c9s merged 3 commits intomainfrom
feature/support-default-method-valuer

Conversation

@c9s
Copy link
Owner

@c9s c9s commented Aug 22, 2025

Usage

users can now customize the default valuer by defining a method:

func (r *Request) GetDefaultClientOrderID() string { ... }
struct {
clientOrderID string `param:"clientOrderID" defaultValuer:"method"`
}

@c9s c9s requested a review from bailantaotao August 22, 2025 07:32
go.mod Outdated
module github.com/c9s/requestgen

go 1.21.0
go 1.23.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be at least 1.24?

Copy link
Owner Author

Choose a reason for hiding this comment

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

We can update to 1.24

@gx578007 gx578007 requested a review from Copilot August 22, 2025 07:36
Copy link

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 adds support for method-based default values in the requestgen code generator, allowing users to define custom default values by implementing methods like GetDefaultFieldName(). The changes update Go toolchain dependencies and enhance the generated code with better parameter handling and validation.

  • Adds method-based default valuer support with defaultValuer:"method" tag option
  • Updates Go toolchain from 1.21.0 to 1.23.0 and dependency versions
  • Improves generated code with slice parameter handling and response unmarshaling

Reviewed Changes

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

Show a summary per file
File Description
go.mod Updates Go version to 1.23.0 and dependency versions
example/api/place_order_request.go Adds Meta struct and demonstrates method-based default valuer usage
example/api/place_order_request_requestgen.go Shows generated code with new method-based defaults and improved parameter handling
cmd/requestgen/main.go Implements core logic for method-based default valuers and field parsing
cmd/requestgen/field.go Adds ReceiverName and IsPointer fields to support new functionality
cmd/requestgen/tmplfuncs.go Adds title function for method name generation
cmd/requestgen/utils.go Improves logging with proper log levels
example/api/v1/*.go Generated code updates showing slice handling and response validation improvements

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@c9s c9s merged commit e8fe5e6 into main Aug 22, 2025
@c9s c9s deleted the feature/support-default-method-valuer branch August 22, 2025 07:51
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