api.none annotation usage

Introduction

The code generated by hz automatically adds a go tag to the struct, thus facilitating parameter binding. However, some “fields” of the user structure may not want to participate in the parameter binding or serialization process, so we provide the “api.none” annotation to make the go tag of the generated structure’s “fields” be “-”, thus avoiding parameter binding.

Thrift

Definition:

struct HelloReq{
  1: string Hertz (api.none="true");
}

Generated Content:

type HelloReq struct {
	Hertz string `thrift:"Hertz,1" form:"-" json:"-" query:"-"`
}

Protobuf

Definition:

message HelloReq {
  optional string Hertz = 1 [(api.none) = "true"];
}

Generated Content:

type HelloReq struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Hertz *string `protobuf:"bytes,1,opt,name=Hertz" json:"-" form:"-" query:"-"`
}

Last modified July 3, 2023 : Update response.md (0a36fb2)