Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | package common |
| 21 | |
| 22 | import ( |
John Boiles | 5785279 | 2018-01-05 14:37:05 -0800 | [diff] [blame] | 23 | "context" |
| 24 | "encoding/hex" |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 25 | "errors" |
| 26 | "fmt" |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 27 | "time" |
Yuxuan 'fishy' Wang | b71f11e | 2021-03-22 15:01:00 -0700 | [diff] [blame] | 28 | |
Yuxuan 'fishy' Wang | 17373a3 | 2021-08-26 11:04:27 -0700 | [diff] [blame] | 29 | //lint:ignore ST1001 allow dot import here |
Yuxuan 'fishy' Wang | b71f11e | 2021-03-22 15:01:00 -0700 | [diff] [blame] | 30 | . "github.com/apache/thrift/test/go/src/gen/thrifttest" |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | var PrintingHandler = &printingHandler{} |
| 34 | |
| 35 | type printingHandler struct{} |
| 36 | |
| 37 | // Prints "testVoid()" and returns nothing. |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 38 | func (p *printingHandler) TestVoid(ctx context.Context) (err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 39 | fmt.Println("testVoid()") |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | // Prints 'testString("%s")' with thing as '%s' |
| 44 | // @param string thing - the string to print |
| 45 | // @return string - returns the string 'thing' |
| 46 | // |
| 47 | // Parameters: |
| 48 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 49 | func (p *printingHandler) TestString(ctx context.Context, thing string) (r string, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 50 | fmt.Printf("testString(\"%s\")\n", thing) |
| 51 | return thing, nil |
| 52 | } |
| 53 | |
Jens Geyer | fa0796d | 2015-10-16 21:33:39 +0200 | [diff] [blame] | 54 | // Prints 'testBool("%t")' with thing as 'true' or 'false' |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 55 | // @param bool thing - the bool to print |
| 56 | // @return bool - returns the bool 'thing' |
| 57 | // |
| 58 | // Parameters: |
| 59 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 60 | func (p *printingHandler) TestBool(ctx context.Context, thing bool) (r bool, err error) { |
Jens Geyer | fa0796d | 2015-10-16 21:33:39 +0200 | [diff] [blame] | 61 | fmt.Printf("testBool(%t)\n", thing) |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 62 | return thing, nil |
| 63 | } |
| 64 | |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 65 | // Prints 'testByte("%d")' with thing as '%d' |
| 66 | // @param byte thing - the byte to print |
| 67 | // @return byte - returns the byte 'thing' |
| 68 | // |
| 69 | // Parameters: |
| 70 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 71 | func (p *printingHandler) TestByte(ctx context.Context, thing int8) (r int8, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 72 | fmt.Printf("testByte(%d)\n", thing) |
| 73 | return thing, nil |
| 74 | } |
| 75 | |
| 76 | // Prints 'testI32("%d")' with thing as '%d' |
| 77 | // @param i32 thing - the i32 to print |
| 78 | // @return i32 - returns the i32 'thing' |
| 79 | // |
| 80 | // Parameters: |
| 81 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 82 | func (p *printingHandler) TestI32(ctx context.Context, thing int32) (r int32, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 83 | fmt.Printf("testI32(%d)\n", thing) |
| 84 | return thing, nil |
| 85 | } |
| 86 | |
| 87 | // Prints 'testI64("%d")' with thing as '%d' |
| 88 | // @param i64 thing - the i64 to print |
| 89 | // @return i64 - returns the i64 'thing' |
| 90 | // |
| 91 | // Parameters: |
| 92 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 93 | func (p *printingHandler) TestI64(ctx context.Context, thing int64) (r int64, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 94 | fmt.Printf("testI64(%d)\n", thing) |
| 95 | return thing, nil |
| 96 | } |
| 97 | |
| 98 | // Prints 'testDouble("%f")' with thing as '%f' |
| 99 | // @param double thing - the double to print |
| 100 | // @return double - returns the double 'thing' |
| 101 | // |
| 102 | // Parameters: |
| 103 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 104 | func (p *printingHandler) TestDouble(ctx context.Context, thing float64) (r float64, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 105 | fmt.Printf("testDouble(%f)\n", thing) |
| 106 | return thing, nil |
| 107 | } |
| 108 | |
Jens Geyer | 8bcfdd9 | 2014-12-14 03:14:26 +0100 | [diff] [blame] | 109 | // Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data |
| 110 | // @param []byte thing - the binary to print |
| 111 | // @return []byte - returns the binary 'thing' |
| 112 | // |
| 113 | // Parameters: |
| 114 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 115 | func (p *printingHandler) TestBinary(ctx context.Context, thing []byte) (r []byte, err error) { |
Jens Geyer | 8bcfdd9 | 2014-12-14 03:14:26 +0100 | [diff] [blame] | 116 | fmt.Printf("testBinary(%s)\n", hex.EncodeToString(thing)) |
| 117 | return thing, nil |
| 118 | } |
| 119 | |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 120 | // Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 121 | // @param Xtruct thing - the Xtruct to print |
| 122 | // @return Xtruct - returns the Xtruct 'thing' |
| 123 | // |
| 124 | // Parameters: |
| 125 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 126 | func (p *printingHandler) TestStruct(ctx context.Context, thing *Xtruct) (r *Xtruct, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 127 | fmt.Printf("testStruct({\"%s\", %d, %d, %d})\n", thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing) |
| 128 | return thing, err |
| 129 | } |
| 130 | |
| 131 | // Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct |
| 132 | // @param Xtruct2 thing - the Xtruct2 to print |
| 133 | // @return Xtruct2 - returns the Xtruct2 'thing' |
| 134 | // |
| 135 | // Parameters: |
| 136 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 137 | func (p *printingHandler) TestNest(ctx context.Context, nest *Xtruct2) (r *Xtruct2, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 138 | thing := nest.StructThing |
| 139 | fmt.Printf("testNest({%d, {\"%s\", %d, %d, %d}, %d})\n", nest.ByteThing, thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing, nest.I32Thing) |
| 140 | return nest, nil |
| 141 | } |
| 142 | |
| 143 | // Prints 'testMap("{%s")' where thing has been formatted into a string of 'key => value' pairs |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 144 | // separated by commas and new lines |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 145 | // @param map<i32,i32> thing - the map<i32,i32> to print |
| 146 | // @return map<i32,i32> - returns the map<i32,i32> 'thing' |
| 147 | // |
| 148 | // Parameters: |
| 149 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 150 | func (p *printingHandler) TestMap(ctx context.Context, thing map[int32]int32) (r map[int32]int32, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 151 | fmt.Printf("testMap({") |
| 152 | first := true |
| 153 | for k, v := range thing { |
| 154 | if first { |
| 155 | first = false |
| 156 | } else { |
| 157 | fmt.Printf(", ") |
| 158 | } |
| 159 | fmt.Printf("%d => %d", k, v) |
| 160 | } |
| 161 | fmt.Printf("})\n") |
| 162 | return thing, nil |
| 163 | } |
| 164 | |
| 165 | // Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 166 | // separated by commas and new lines |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 167 | // @param map<string,string> thing - the map<string,string> to print |
| 168 | // @return map<string,string> - returns the map<string,string> 'thing' |
| 169 | // |
| 170 | // Parameters: |
| 171 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 172 | func (p *printingHandler) TestStringMap(ctx context.Context, thing map[string]string) (r map[string]string, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 173 | fmt.Printf("testStringMap({") |
| 174 | first := true |
| 175 | for k, v := range thing { |
| 176 | if first { |
| 177 | first = false |
| 178 | } else { |
| 179 | fmt.Printf(", ") |
| 180 | } |
| 181 | fmt.Printf("%s => %s", k, v) |
| 182 | } |
| 183 | fmt.Printf("})\n") |
| 184 | return thing, nil |
| 185 | } |
| 186 | |
| 187 | // Prints 'testSet("{%s}")' where thing has been formatted into a string of values |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 188 | // separated by commas and new lines |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 189 | // @param set<i32> thing - the set<i32> to print |
| 190 | // @return set<i32> - returns the set<i32> 'thing' |
| 191 | // |
| 192 | // Parameters: |
| 193 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 194 | func (p *printingHandler) TestSet(ctx context.Context, thing []int32) (r []int32, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 195 | fmt.Printf("testSet({") |
| 196 | first := true |
Yuxuan 'fishy' Wang | b71f11e | 2021-03-22 15:01:00 -0700 | [diff] [blame] | 197 | for k := range thing { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 198 | if first { |
| 199 | first = false |
| 200 | } else { |
| 201 | fmt.Printf(", ") |
| 202 | } |
| 203 | fmt.Printf("%d", k) |
| 204 | } |
| 205 | fmt.Printf("})\n") |
| 206 | return thing, nil |
| 207 | } |
| 208 | |
| 209 | // Prints 'testList("{%s}")' where thing has been formatted into a string of values |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 210 | // separated by commas and new lines |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 211 | // @param list<i32> thing - the list<i32> to print |
| 212 | // @return list<i32> - returns the list<i32> 'thing' |
| 213 | // |
| 214 | // Parameters: |
| 215 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 216 | func (p *printingHandler) TestList(ctx context.Context, thing []int32) (r []int32, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 217 | fmt.Printf("testList({") |
| 218 | for i, v := range thing { |
| 219 | if i != 0 { |
| 220 | fmt.Printf(", ") |
| 221 | } |
| 222 | fmt.Printf("%d", v) |
| 223 | } |
| 224 | fmt.Printf("})\n") |
| 225 | return thing, nil |
| 226 | } |
| 227 | |
| 228 | // Prints 'testEnum("%d")' where thing has been formatted into it's numeric value |
| 229 | // @param Numberz thing - the Numberz to print |
| 230 | // @return Numberz - returns the Numberz 'thing' |
| 231 | // |
| 232 | // Parameters: |
| 233 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 234 | func (p *printingHandler) TestEnum(ctx context.Context, thing Numberz) (r Numberz, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 235 | fmt.Printf("testEnum(%d)\n", thing) |
| 236 | return thing, nil |
| 237 | } |
| 238 | |
| 239 | // Prints 'testTypedef("%d")' with thing as '%d' |
| 240 | // @param UserId thing - the UserId to print |
| 241 | // @return UserId - returns the UserId 'thing' |
| 242 | // |
| 243 | // Parameters: |
| 244 | // - Thing |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 245 | func (p *printingHandler) TestTypedef(ctx context.Context, thing UserId) (r UserId, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 246 | fmt.Printf("testTypedef(%d)\n", thing) |
| 247 | return thing, nil |
| 248 | } |
| 249 | |
| 250 | // Prints 'testMapMap("%d")' with hello as '%d' |
| 251 | // @param i32 hello - the i32 to print |
| 252 | // @return map<i32,map<i32,i32>> - returns a dictionary with these values: |
| 253 | // {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, } |
| 254 | // |
| 255 | // Parameters: |
| 256 | // - Hello |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 257 | func (p *printingHandler) TestMapMap(ctx context.Context, hello int32) (r map[int32]map[int32]int32, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 258 | fmt.Printf("testMapMap(%d)\n", hello) |
| 259 | |
| 260 | r = map[int32]map[int32]int32{ |
Yuxuan 'fishy' Wang | b71f11e | 2021-03-22 15:01:00 -0700 | [diff] [blame] | 261 | -4: {-4: -4, -3: -3, -2: -2, -1: -1}, |
| 262 | 4: {4: 4, 3: 3, 2: 2, 1: 1}, |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 263 | } |
| 264 | return |
| 265 | } |
| 266 | |
| 267 | // So you think you've got this all worked, out eh? |
| 268 | // |
| 269 | // Creates a the returned map with these values and prints it out: |
| 270 | // { 1 => { 2 => argument, |
| 271 | // 3 => argument, |
| 272 | // }, |
| 273 | // 2 => { 6 => <empty Insanity struct>, }, |
| 274 | // } |
| 275 | // @return map<UserId, map<Numberz,Insanity>> - a map with the above values |
| 276 | // |
| 277 | // Parameters: |
| 278 | // - Argument |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 279 | func (p *printingHandler) TestInsanity(ctx context.Context, argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) { |
Nobuaki Sukegawa | 2fab3de | 2015-08-16 15:42:58 +0900 | [diff] [blame] | 280 | fmt.Printf("testInsanity()\n") |
| 281 | r = make(map[UserId]map[Numberz]*Insanity) |
John Boiles | 5785279 | 2018-01-05 14:37:05 -0800 | [diff] [blame] | 282 | r[1] = map[Numberz]*Insanity{ |
Nobuaki Sukegawa | 2fab3de | 2015-08-16 15:42:58 +0900 | [diff] [blame] | 283 | 2: argument, |
| 284 | 3: argument, |
| 285 | } |
John Boiles | 5785279 | 2018-01-05 14:37:05 -0800 | [diff] [blame] | 286 | r[2] = map[Numberz]*Insanity{ |
Nobuaki Sukegawa | 2fab3de | 2015-08-16 15:42:58 +0900 | [diff] [blame] | 287 | 6: NewInsanity(), |
| 288 | } |
| 289 | return |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | // Prints 'testMulti()' |
| 293 | // @param byte arg0 - |
| 294 | // @param i32 arg1 - |
| 295 | // @param i64 arg2 - |
| 296 | // @param map<i16, string> arg3 - |
| 297 | // @param Numberz arg4 - |
| 298 | // @param UserId arg5 - |
| 299 | // @return Xtruct - returns an Xtruct with StringThing = "Hello2, ByteThing = arg0, I32Thing = arg1 |
| 300 | // and I64Thing = arg2 |
| 301 | // |
| 302 | // Parameters: |
| 303 | // - Arg0 |
| 304 | // - Arg1 |
| 305 | // - Arg2 |
| 306 | // - Arg3 |
| 307 | // - Arg4 |
| 308 | // - Arg5 |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 309 | func (p *printingHandler) TestMulti(ctx context.Context, arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 310 | fmt.Printf("testMulti()\n") |
| 311 | r = NewXtruct() |
| 312 | |
| 313 | r.StringThing = "Hello2" |
| 314 | r.ByteThing = arg0 |
| 315 | r.I32Thing = arg1 |
| 316 | r.I64Thing = arg2 |
| 317 | return |
| 318 | } |
| 319 | |
| 320 | // Print 'testException(%s)' with arg as '%s' |
| 321 | // @param string arg - a string indication what type of exception to throw |
| 322 | // if arg == "Xception" throw Xception with errorCode = 1001 and message = arg |
| 323 | // elsen if arg == "TException" throw TException |
| 324 | // else do not throw anything |
| 325 | // |
| 326 | // Parameters: |
| 327 | // - Arg |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 328 | func (p *printingHandler) TestException(ctx context.Context, arg string) (err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 329 | fmt.Printf("testException(%s)\n", arg) |
| 330 | switch arg { |
| 331 | case "Xception": |
| 332 | e := NewXception() |
| 333 | e.ErrorCode = 1001 |
| 334 | e.Message = arg |
| 335 | return e |
| 336 | case "TException": |
Yuxuan 'fishy' Wang | 17373a3 | 2021-08-26 11:04:27 -0700 | [diff] [blame] | 337 | //lint:ignore ST1005 To be consistent with other language libraries. |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 338 | return errors.New("Just TException") |
| 339 | } |
| 340 | return |
| 341 | } |
| 342 | |
| 343 | // Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s' |
| 344 | // @param string arg - a string indication what type of exception to throw |
| 345 | // if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception" |
| 346 | // elsen if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and message = "This is an Xception2" |
| 347 | // else do not throw anything |
| 348 | // @return Xtruct - an Xtruct with StringThing = arg1 |
| 349 | // |
| 350 | // Parameters: |
| 351 | // - Arg0 |
| 352 | // - Arg1 |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 353 | func (p *printingHandler) TestMultiException(ctx context.Context, arg0 string, arg1 string) (r *Xtruct, err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 354 | fmt.Printf("testMultiException(%s, %s)\n", arg0, arg1) |
| 355 | switch arg0 { |
| 356 | |
| 357 | case "Xception": |
| 358 | e := NewXception() |
| 359 | e.ErrorCode = 1001 |
| 360 | e.Message = "This is an Xception" |
| 361 | return nil, e |
| 362 | case "Xception2": |
| 363 | e := NewXception2() |
| 364 | e.ErrorCode = 2002 |
| 365 | e.StructThing = NewXtruct() |
| 366 | e.StructThing.StringThing = "This is an Xception2" |
| 367 | return nil, e |
| 368 | default: |
| 369 | r = NewXtruct() |
| 370 | r.StringThing = arg1 |
| 371 | return |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | // Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d' |
| 376 | // sleep 'secondsToSleep' |
| 377 | // Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d' |
| 378 | // @param i32 secondsToSleep - the number of seconds to sleep |
| 379 | // |
| 380 | // Parameters: |
| 381 | // - SecondsToSleep |
taozle | c0d384a | 2017-07-17 18:40:42 +0200 | [diff] [blame] | 382 | func (p *printingHandler) TestOneway(ctx context.Context, secondsToSleep int32) (err error) { |
Jens Geyer | f459868 | 2014-05-08 23:18:44 +0200 | [diff] [blame] | 383 | fmt.Printf("testOneway(%d): Sleeping...\n", secondsToSleep) |
| 384 | time.Sleep(time.Second * time.Duration(secondsToSleep)) |
| 385 | fmt.Printf("testOneway(%d): done sleeping!\n", secondsToSleep) |
| 386 | return |
| 387 | } |