github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/sample/example2.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/example2"
    24  )
    25  
    26  var (
    27  	Example2Obj   = GetExample2Req()
    28  	Example2Super = GetExample2ReqSuper()
    29  )
    30  
    31  func GetBase() *base.Base {
    32  	ret := base.NewBase()
    33  	ret.LogID = "log_id"
    34  	ret.TrafficEnv = &base.TrafficEnv{
    35  		Open: true,
    36  		Env:  "env",
    37  	}
    38  	ret.Extra = map[string]string{"a": "A", "c": "C", "b": "B"}
    39  	return ret
    40  }
    41  
    42  func GetExample2Req() *example2.ExampleReq {
    43  	obj := example2.NewExampleReq()
    44  	obj.Msg = new(string)
    45  	*obj.Msg = "hello"
    46  	obj.Subfix = math.MaxFloat64
    47  	obj.InnerBase = example2.NewInnerBase()
    48  	obj.InnerBase.Binary = []byte{0xff, 0xff, 0xff, 0xff}
    49  	obj.InnerBase.Bool = true
    50  	obj.InnerBase.Byte = math.MaxInt8
    51  	obj.InnerBase.Int16 = math.MinInt16
    52  	obj.InnerBase.Int32 = math.MaxInt32
    53  	obj.InnerBase.Int64 = math.MinInt64
    54  	obj.InnerBase.Double = math.MaxFloat64
    55  	obj.InnerBase.String_ = "你好"
    56  	obj.InnerBase.ListInt32 = []int32{math.MinInt32, 0, math.MaxInt32}
    57  	obj.InnerBase.SetInt32_ = []int32{math.MinInt32, 0, math.MaxInt32}
    58  	obj.InnerBase.MapStringString = map[string]string{"a": "A", "c": "C", "b": "B"}
    59  	obj.InnerBase.Foo = 1
    60  	obj.InnerBase.MapInt8String = map[int8]string{1: "A", 2: "B", 3: "C"}
    61  	obj.InnerBase.MapInt16String = map[int16]string{1: "A", 2: "B", 3: "C"}
    62  	obj.InnerBase.MapInt32String = map[int32]string{1: "A", 2: "B", 3: "C"}
    63  	obj.InnerBase.MapInt64String = map[int64]string{1: "A", 2: "B", 3: "C"}
    64  	obj.InnerBase.MapDoubleString = map[float64]string{0.1: "A", 0.2: "B", 0.3: "C"}
    65  
    66  	innerx := example2.NewInnerBase()
    67  	innerx.Base = GetBase()
    68  	obj.InnerBase.ListInnerBase = []*example2.InnerBase{
    69  		innerx,
    70  	}
    71  	obj.InnerBase.MapInnerBaseInnerBase = map[*example2.InnerBase]*example2.InnerBase{
    72  		innerx: innerx,
    73  	}
    74  
    75  	obj.InnerBase.Base = GetBase()
    76  	obj.InnerBase.Base.LogID = "log_id_inner"
    77  	obj.InnerBase.Base.TrafficEnv = &base.TrafficEnv{
    78  		Open: true,
    79  		Env:  "env_inner",
    80  	}
    81  	obj.Base = GetBase()
    82  	return obj
    83  }
    84  
    85  func GetExample2ReqSuper() *example2.ExampleSuper {
    86  	obj := example2.NewExampleSuper()
    87  	obj.Ex1 = "ex"
    88  	ex2 := "ex"
    89  	obj.Ex2 = &ex2
    90  	obj.Ex4 = "ex"
    91  	// obj.MapStructStruct = map[*example2.BasePartial]*example2.BasePartial{
    92  	// 	example2.NewBasePartial(): example2.NewBasePartial(),
    93  	// }
    94  	self := example2.NewSelfRef()
    95  	self.Self = example2.NewSelfRef()
    96  	obj.SelfRef = self
    97  
    98  	c := GetExample2Req()
    99  	obj.InnerBase = c.InnerBase
   100  	obj.Msg = c.Msg
   101  	obj.Base = c.Base
   102  	obj.Subfix = c.Subfix
   103  	return obj
   104  }