2018-07-28 18:07:31 +02:00
package fixtures
2019-06-01 10:34:43 +02:00
import "time"
2018-07-28 18:07:31 +02:00
type decodeAndValidateRequest struct {
2025-04-10 08:47:55 +03:00
// BEWARE : the flag of URLParam should match the const string URLParam
2022-07-14 02:26:44 +08:00
URLParam string ` json:"-" path:"url_param" validate:"numeric" `
Text string ` json:"text" validate:"max=10" `
2025-04-10 07:43:35 +02:00
DefaultInt int ` json:"defaultInt" default:"10.0" ` // MATCH /type mismatch between field type and default value type in default tag/
2022-07-14 02:26:44 +08:00
DefaultInt2 int ` json:"defaultInt2" default:"10" `
2025-04-10 07:43:35 +02:00
// MATCH:12 /unknown option "inline" in json tag/
DefaultInt3 int ` json:"defaultInt2,inline" default:"11" ` // MATCH /duplicated tag name "defaultInt2" in json tag/
2018-07-28 18:07:31 +02:00
DefaultString string ` json:"defaultString" default:"foo" `
2025-04-10 07:43:35 +02:00
DefaultBool bool ` json:"defaultBool" default:"trues" ` // MATCH /type mismatch between field type and default value type in default tag/
2022-07-14 02:26:44 +08:00
DefaultBool2 bool ` json:"defaultBool2" default:"true" `
DefaultBool3 bool ` json:"defaultBool3" default:"false" `
2025-04-10 07:43:35 +02:00
DefaultFloat float64 ` json:"defaultFloat" default:"f10.0" ` // MATCH /type mismatch between field type and default value type in default tag/
2022-07-14 02:26:44 +08:00
DefaultFloat2 float64 ` json:"defaultFloat2" default:"10.0" `
2025-04-10 07:43:35 +02:00
MandatoryStruct mandatoryStruct ` json:"mandatoryStruct" required:"trues" ` // MATCH /required should be "true" or "false" in required tag/
2022-07-14 02:26:44 +08:00
MandatoryStruct2 mandatoryStruct ` json:"mandatoryStruct2" required:"true" `
MandatoryStruct4 mandatoryStruct ` json:"mandatoryStruct4" required:"false" `
2018-07-28 18:07:31 +02:00
OptionalStruct * optionalStruct ` json:"optionalStruct,omitempty" `
OptionalQuery string ` json:"-" querystring:"queryfoo" `
2019-06-01 10:34:43 +02:00
optionalQuery string ` json:"-" querystring:"queryfoo" ` // MATCH /tag on not-exported field optionalQuery/
2019-08-05 18:21:20 +02:00
// No-reg test for bug https://github.com/mgechev/revive/issues/208
2025-02-16 11:31:17 +01:00
Tiret string ` json:"-," `
2025-04-10 07:43:35 +02:00
BadTiret string ` json:"other," ` // MATCH /option can not be empty in json tag/
ForOmitzero string ` json:"forOmitZero,omitzero" ` // MATCH /prior Go 1.24, option "omitzero" is unsupported in json tag/
// MATCH:30 /option can not be empty in json tag/
BadTiret string ` json:"other," ` // MATCH /duplicated tag name "other" in json tag/
2018-07-28 18:07:31 +02:00
}
type RangeAllocation struct {
2025-04-10 07:43:35 +02:00
metav1 . TypeMeta ` json:",inline" ` // MATCH /unknown option "inline" in json tag/
2018-07-28 18:07:31 +02:00
metav1 . ObjectMeta ` json:"metadata,omitempty" `
2025-04-10 07:43:35 +02:00
Range string ` json:"range,flow" ` // MATCH /unknown option "flow" in json tag/
Data [ ] byte ` json:"data,inline" ` // MATCH /unknown option "inline" in json tag/
2018-07-28 18:07:31 +02:00
}
2018-08-07 20:28:45 +02:00
type RangeAllocation struct {
metav1 . TypeMeta ` bson:",minsize" `
metav1 . ObjectMeta ` bson:"metadata,omitempty" `
2025-04-10 07:43:35 +02:00
Range string ` bson:"range,flow" ` // MATCH /unknown option "flow" in bson tag/
2018-08-07 20:28:45 +02:00
Data [ ] byte ` bson:"data,inline" `
}
type TestContextSpecificTags2 struct {
A int ` asn1:"explicit,tag:1" `
B int ` asn1:"tag:2" `
S string ` asn1:"tag:0,utf8" `
Ints [ ] int ` asn1:"set" `
2025-04-10 07:43:35 +02:00
Version int ` asn1:"optional,explicit,default:0,tag:000" ` // MATCH /duplicated tag number 0 in asn1 tag/
Time time . Time ` asn1:"explicit,tag:4,other" ` // MATCH /unknown option "other" in asn1 tag/
X int ` asn1:"explicit,tag:invalid" ` // MATCH /tag must be a number but is "invalid" in asn1 tag/
2018-08-07 20:28:45 +02:00
}
2018-07-28 18:07:31 +02:00
type VirtualMachineRelocateSpecDiskLocator struct {
DynamicData
DiskId int32 ` xml:"diskId,attr,cdata" `
Datastore ManagedObjectReference ` xml:"datastore,chardata,innerxml" `
DiskMoveType string ` xml:"diskMoveType,omitempty,comment" `
DiskBackingInfo BaseVirtualDeviceBackingInfo ` xml:"diskBackingInfo,omitempty,any" `
2025-04-10 07:43:35 +02:00
Profile [ ] BaseVirtualMachineProfileSpec ` xml:"profile,omitempty,other" ` // MATCH /unknown option "other" in xml tag/
2018-07-28 18:07:31 +02:00
}
2022-07-14 02:26:44 +08:00
2025-04-10 07:43:35 +02:00
type TestDuplicatedxmlTags struct {
2022-07-14 02:26:44 +08:00
A int ` xml:"a" `
2025-04-10 07:43:35 +02:00
B int ` xml:"a" ` // MATCH /duplicated tag name "a" in xml tag/
2022-07-14 02:26:44 +08:00
C int ` xml:"c" `
}
2025-04-10 07:43:35 +02:00
type TestDuplicatedbsonTags struct {
2022-07-14 02:26:44 +08:00
A int ` bson:"b" `
2025-04-10 07:43:35 +02:00
B int ` bson:"b" ` // MATCH /duplicated tag name "b" in bson tag/
2022-07-14 02:26:44 +08:00
C int ` bson:"c" `
}
type TestDuplicatedYAMLTags struct {
A int ` yaml:"b" `
B int ` yaml:"c" `
2025-04-10 07:43:35 +02:00
C int ` yaml:"c" ` // MATCH /duplicated tag name "c" in yaml tag/
2022-07-14 02:26:44 +08:00
}
type TestDuplicatedProtobufTags struct {
A int ` protobuf:"varint,name=b" `
B int ` protobuf:"varint,name=c" `
2025-04-10 07:43:35 +02:00
C int ` protobuf:"varint,name=c" ` // MATCH /duplicated tag name "c" in protobuf tag/
2022-07-14 02:26:44 +08:00
}
// test case from
// sigs.k8s.io/kustomize/api/types/helmchartargs.go
type HelmChartArgs struct {
ChartName string ` json:"chartName,omitempty" yaml:"chartName,omitempty" `
ChartVersion string ` json:"chartVersion,omitempty" yaml:"chartVersion,omitempty" `
ChartRepoURL string ` json:"chartRepoUrl,omitempty" yaml:"chartRepoUrl,omitempty" `
ChartHome string ` json:"chartHome,omitempty" yaml:"chartHome,omitempty" `
ChartRepoName string ` json:"chartRepoName,omitempty" yaml:"chartRepoName,omitempty" `
HelmBin string ` json:"helmBin,omitempty" yaml:"helmBin,omitempty" `
HelmHome string ` json:"helmHome,omitempty" yaml:"helmHome,omitempty" `
Values string ` json:"values,omitempty" yaml:"values,omitempty" `
ValuesLocal map [ string ] interface { } ` json:"valuesLocal,omitempty" yaml:"valuesLocal,omitempty" `
ValuesMerge string ` json:"valuesMerge,omitempty" yaml:"valuesMerge,omitempty" `
ReleaseName string ` json:"releaseName,omitempty" yaml:"releaseName,omitempty" `
ReleaseNamespace string ` json:"releaseNamespace,omitempty" yaml:"releaseNamespace,omitempty" `
ExtraArgs [ ] string ` json:"extraArgs,omitempty" yaml:"extraArgs,omitempty" `
}
2022-07-15 20:15:55 +02:00
// Test message for holding primitive types.
type Simple struct {
2025-04-10 07:43:35 +02:00
OBool * bool ` protobuf:"varint,1,req,json=oBool" ` // MATCH /mandatory option "name" not found in protobuf tag/
OInt32 * int32 ` protobuf:"varint,2,opt,name=o_int32,jsonx=oInt32" ` // MATCH /unknown option "jsonx" in protobuf tag/
OInt32Str * int32 ` protobuf:"varint,3,rep,name=o_int32_str,name=oInt32Str" ` // MATCH /duplicated option "name" in protobuf tag/
OInt64 * int64 ` protobuf:"varint,4,opt,json=oInt64,name=o_int64,json=oInt64" ` // MATCH /duplicated option "json" in protobuf tag/
2022-07-15 20:15:55 +02:00
OSint32Str * int32 ` protobuf:"zigzag32,11,opt,name=o_sint32_str,json=oSint32Str" `
2025-04-10 07:43:35 +02:00
OSint64Str * int64 ` protobuf:"zigzag64,13,opt,name=o_sint32_str,json=oSint64Str" ` // MATCH /duplicated tag name "o_sint32_str" in protobuf tag/
2022-07-15 20:15:55 +02:00
OFloat * float32 ` protobuf:"fixed32,14,opt,name=o_float,json=oFloat" `
2025-04-10 07:43:35 +02:00
ODouble * float64 ` protobuf:"fixed64,014,opt,name=o_double,json=oDouble" ` // MATCH /duplicated tag number 14 in protobuf tag/
ODoubleStr * float64 ` protobuf:"fixed6,17,opt,name=o_double_str,json=oDoubleStr" ` // MATCH /invalid tag name "fixed6" in protobuf tag/
2022-07-15 20:15:55 +02:00
OString * string ` protobuf:"bytes,18,opt,name=o_string,json=oString" `
2023-05-16 09:09:20 +03:00
OString2 * string ` protobuf:"bytes,name=ameno" `
2025-04-10 07:43:35 +02:00
OString3 * string ` protobuf:"bytes,name=ameno" ` // MATCH /duplicated tag name "ameno" in protobuf tag/
2022-07-15 20:15:55 +02:00
XXX_NoUnkeyedLiteral struct { } ` json:"-" `
XXX_unrecognized [ ] byte ` json:"-" `
XXX_sizecache int32 ` json:"-" `
}
2025-02-17 07:18:30 +01:00
type RequestQueryOption struct {
Properties [ ] string ` url:"properties,comma,omitempty" `
CustomProperties [ ] string ` url:"-" `
Associations [ ] string ` url:"associations,brackets,omitempty" `
Associations2 [ ] string ` url:"associations2,semicolon,omitempty" `
Associations3 [ ] string ` url:"associations3,space,brackets,omitempty" `
Associations4 [ ] string ` url:"associations4,numbered,omitempty" `
2025-04-10 07:43:35 +02:00
Associations5 [ ] string ` url:"associations5,space,semicolon,omitempty" ` // MATCH /can not set both "semicolon" and "space" as delimiters in url tag/
2025-02-17 07:18:30 +01:00
PaginateAssociations bool ` url:"paginateAssociations,int,omitempty" `
2025-04-10 07:43:35 +02:00
Archived bool ` url:"archived,myURLOption" ` // MATCH /unknown option "myURLOption" in url tag/
2025-02-17 07:18:30 +01:00
IDProperty string ` url:"idProperty,omitempty" `
}
2025-02-18 13:09:31 +01:00
type Fields struct {
Field string ` datastore:",noindex,flatten,omitempty" `
2025-04-10 07:43:35 +02:00
OtherField string ` datastore:",unknownOption" ` // MATCH /unknown option "unknownOption" in datastore tag/
2025-02-18 13:09:31 +01:00
}
2025-02-19 14:30:29 +01:00
type MapStruct struct {
Field1 string ` mapstructure:",squash,reminder,omitempty" `
2025-04-10 07:43:35 +02:00
OtherField string ` mapstructure:",unknownOption" ` // MATCH /unknown option "unknownOption" in mapstructure tag/
2025-02-19 14:30:29 +01:00
}
2025-02-20 19:48:35 +01:00
type ValidateUser struct {
Username string ` validate:"required,min=3,max=32" `
Email string ` validate:"required,email" `
Password string ` validate:"required,min=8,max=32" `
Biography string ` validate:"min=0,max=1000" `
2025-04-10 07:43:35 +02:00
DisplayName string ` validate:"displayName,min=3,max=32" ` // MATCH /unknown option "displayName" in validate tag/
2025-02-20 19:48:35 +01:00
Complex string ` validate:"gt=0,dive,keys,eq=1|eq=2,endkeys,required" `
2025-04-10 07:43:35 +02:00
BadComplex string ` validate:"gt=0,keys,eq=1|eq=2,endkeys,required" ` // MATCH /option "keys" must follow a "dive" option in validate tag/
BadComplex2 string ` validate:"gt=0,dive,eq=1|eq=2,endkeys,required" ` // MATCH /option "endkeys" without a previous "keys" option in validate tag/
BadComplex3 string ` validate:"gt=0,dive,keys,eq=1|eq=2,endkeys,endkeys,required" ` // MATCH /option "endkeys" without a previous "keys" option in validate tag/
2025-02-20 19:48:35 +01:00
}
2025-03-03 13:19:40 +01:00
type TomlUser struct {
Username string ` toml:"username,omitempty" `
2025-04-10 07:43:35 +02:00
Location string ` toml:"location,unknown" ` // MATCH /unknown option "unknown" in toml tag/
2025-03-03 13:19:40 +01:00
}
2025-04-05 08:38:59 +02:00
type PropertiesTags struct {
Field int ` properties:"-" `
Field int ` properties:"myName" `
Field int ` properties:"myName,default=15" `
2025-04-10 07:43:35 +02:00
Field int ` properties:"myName,default=sString" ` // MATCH /type mismatch between field type and default value type in properties tag/
Field int ` properties:",default:15" ` // MATCH /unknown or malformed option "default:15" in properties tag/
Field int ` properties:",default=15,default=2" ` // MATCH /duplicated option "default" in properties tag/
2025-04-05 08:38:59 +02:00
Field time . Time ` properties:"date,layout=2006-01-02" `
Field time . Time ` properties:",layout=2006-01-02" `
2025-04-10 07:43:35 +02:00
Field time . Time ` properties:"date,layout" ` // MATCH /unknown or malformed option "layout" in properties tag/
Field time . Time ` properties:"date,layout= " ` // MATCH /option "layout" not of the form layout=value in properties tag/
2025-04-05 08:38:59 +02:00
Field string ` properties:"date,layout=2006-01-02" ` // MATCH /layout option is only applicable to fields of type time.Time in properties tag/
Field [ ] string ` properties:",default=a;b;c" `
2025-04-10 07:43:35 +02:00
Field map [ string ] string ` properties:"myName,omitempty" ` // MATCH /unknown or malformed option "omitempty" in properties tag/
2025-04-05 08:38:59 +02:00
}