github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/sample/example3.go (about) 1 /** 2 * Copyright 2023 CloudWeGo Authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package sample 18 19 import ( 20 "math" 21 22 "github.com/cloudwego/dynamicgo/testdata/kitex_gen/base" 23 "github.com/cloudwego/dynamicgo/testdata/kitex_gen/example3" 24 ) 25 26 func GetEmptyInnerBase3() *example3.InnerBase { 27 return &example3.InnerBase{ 28 ListInt32: []int32{}, 29 MapStringString: map[string]string{}, 30 SetInt32_: []int32{}, 31 MapInt32String: map[int32]string{}, 32 Binary: []byte{}, 33 MapInt8String: map[int8]string{}, 34 MapInt16String: map[int16]string{}, 35 MapInt64String: map[int64]string{}, 36 ListInnerBase: []*example3.InnerBase{}, 37 MapStringInnerBase: map[string]*example3.InnerBase{}, 38 Base: &base.Base{}, 39 } 40 } 41 42 func GetInnerBase3() *example3.InnerBase { 43 in := example3.NewInnerBase() 44 in.Binary = []byte{0xff, 0xff, 0xff, 0xff} 45 in.Bool = true 46 in.Byte = math.MaxInt8 47 in.Int16 = math.MinInt16 48 in.Int32 = math.MaxInt32 49 in.Int64 = math.MinInt64 50 in.Double = math.MaxFloat64 51 in.String_ = "hello" 52 in.ListInt32 = []int32{math.MinInt32, 0, math.MaxInt32} 53 in.SetInt32_ = []int32{math.MinInt32, 0, math.MaxInt32} 54 in.MapStringString = map[string]string{"a": "A", "c": "C", "b": "B"} 55 in.Foo = 1 56 in.MapInt8String = map[int8]string{1: "A", 2: "B", 3: "C"} 57 in.MapInt16String = map[int16]string{1: "A", 2: "B", 3: "C"} 58 in.MapInt32String = map[int32]string{1: "A", 2: "B", 3: "C"} 59 in.MapInt64String = map[int64]string{1: "A", 2: "B", 3: "C"} 60 in.InnerQuery = "中文" 61 62 innerx := GetEmptyInnerBase3() 63 innerx.Base = GetBase() 64 in.ListInnerBase = []*example3.InnerBase{ 65 innerx, 66 } 67 in.MapStringInnerBase = map[string]*example3.InnerBase{ 68 "innerx": innerx, 69 } 70 71 in.Base = GetBase() 72 in.Base.LogID = "log_id_inner" 73 in.Base.TrafficEnv = &base.TrafficEnv{ 74 Open: true, 75 Env: "env_inner", 76 } 77 return in 78 } 79 80 func GetExample3Req() *example3.ExampleReq { 81 obj := example3.NewExampleReq() 82 obj.Msg = new(string) 83 *obj.Msg = "hello" 84 obj.Subfix = math.MaxFloat64 85 obj.InnerBase = GetInnerBase3() 86 obj.Base = GetBase() 87 obj.Code = 1024 88 return obj 89 } 90 91 func GetExample3Resp() *example3.ExampleResp { 92 obj := example3.NewExampleResp() 93 obj.Code = 1024 94 obj.Msg = "中文" 95 obj.Status = 202 96 f := float64(-0.0000001) 97 obj.Cookie = &f 98 b := bool(true) 99 obj.Header = &b 100 obj.Subfix = 0 101 obj.InnerBase = GetInnerBase3() 102 obj.BaseResp = &base.BaseResp{ 103 StatusMessage: "a", 104 StatusCode: 2048, 105 } 106 return obj 107 }