@@ -271,27 +271,27 @@ func setFlags(flags *flagTracker, main interface{}, prefix string) error {
271
271
// now check basic kinds
272
272
switch ft .Type .Kind () {
273
273
case reflect .String :
274
- p := f .Addr ().Interface ().( * string )
274
+ p := ( * string )( f .Addr ().UnsafePointer () )
275
275
flags .string (p , flagName , shorthand , f .String (), flagHelp (ft ))
276
276
case reflect .Bool :
277
- p := f .Addr ().Interface ().( * bool )
277
+ p := ( * bool )( f .Addr ().UnsafePointer () )
278
278
flags .bool (p , flagName , shorthand , f .Bool (), flagHelp (ft ))
279
279
case reflect .Int :
280
- p := f .Addr ().Interface ().( * int )
280
+ p := ( * int )( f .Addr ().UnsafePointer () )
281
281
val := int (f .Int ())
282
282
flags .int (p , flagName , shorthand , val , flagHelp (ft ))
283
283
case reflect .Int64 :
284
- p := f .Addr ().Interface ().( * int64 )
284
+ p := ( * int64 )( f .Addr ().UnsafePointer () )
285
285
flags .int64 (p , flagName , shorthand , f .Int (), flagHelp (ft ))
286
286
case reflect .Float64 :
287
- p := f .Addr ().Interface ().( * float64 )
287
+ p := ( * float64 )( f .Addr ().UnsafePointer () )
288
288
flags .float64 (p , flagName , shorthand , f .Float (), flagHelp (ft ))
289
289
case reflect .Uint :
290
- p := f .Addr ().Interface ().( * uint )
290
+ p := ( * uint )( f .Addr ().UnsafePointer () )
291
291
val := uint (f .Uint ())
292
292
flags .uint (p , flagName , shorthand , val , flagHelp (ft ))
293
293
case reflect .Uint64 :
294
- p := f .Addr ().Interface ().( * uint64 )
294
+ p := ( * uint64 )( f .Addr ().UnsafePointer () )
295
295
flags .uint64 (p , flagName , shorthand , f .Uint (), flagHelp (ft ))
296
296
case reflect .Slice :
297
297
if ! flags .pflag {
@@ -317,43 +317,43 @@ func setFlags(flags *flagTracker, main interface{}, prefix string) error {
317
317
if ! flags .pflag {
318
318
return fmt .Errorf ("cannot support float32 field at '%v' with stdlib flag pkg." , flagName )
319
319
}
320
- p := f .Addr ().Interface ().( * float32 )
320
+ p := ( * float32 )( f .Addr ().UnsafePointer () )
321
321
flags .float32 (p , flagName , shorthand , * p , flagHelp (ft ))
322
322
case reflect .Int16 :
323
323
if ! flags .pflag {
324
324
return fmt .Errorf ("cannot support int16 field at '%v' with stdlib flag pkg." , flagName )
325
325
}
326
- p := f .Addr ().Interface ().( * int16 )
326
+ p := ( * int16 )( f .Addr ().UnsafePointer () )
327
327
flags .int16 (p , flagName , shorthand , * p , flagHelp (ft ))
328
328
case reflect .Int32 :
329
329
if ! flags .pflag {
330
330
return fmt .Errorf ("cannot support int32 field at '%v' with stdlib flag pkg." , flagName )
331
331
}
332
- p := f .Addr ().Interface ().( * int32 )
332
+ p := ( * int32 )( f .Addr ().UnsafePointer () )
333
333
flags .int32 (p , flagName , shorthand , * p , flagHelp (ft ))
334
334
case reflect .Uint16 :
335
335
if ! flags .pflag {
336
336
return fmt .Errorf ("cannot support uint16 field at '%v' with stdlib flag pkg." , flagName )
337
337
}
338
- p := f .Addr ().Interface ().( * uint16 )
338
+ p := ( * uint16 )( f .Addr ().UnsafePointer () )
339
339
flags .uint16 (p , flagName , shorthand , * p , flagHelp (ft ))
340
340
case reflect .Uint32 :
341
341
if ! flags .pflag {
342
342
return fmt .Errorf ("cannot support uint32 field at '%v' with stdlib flag pkg." , flagName )
343
343
}
344
- p := f .Addr ().Interface ().( * uint32 )
344
+ p := ( * uint32 )( f .Addr ().UnsafePointer () )
345
345
flags .uint32 (p , flagName , shorthand , * p , flagHelp (ft ))
346
346
case reflect .Uint8 :
347
347
if ! flags .pflag {
348
348
return fmt .Errorf ("cannot support uint8 field at '%v' with stdlib flag pkg." , flagName )
349
349
}
350
- p := f .Addr ().Interface ().( * uint8 )
350
+ p := ( * uint8 )( f .Addr ().UnsafePointer () )
351
351
flags .uint8 (p , flagName , shorthand , * p , flagHelp (ft ))
352
352
case reflect .Int8 :
353
353
if ! flags .pflag {
354
354
return fmt .Errorf ("cannot support int8 field at '%v' with stdlib flag pkg." , flagName )
355
355
}
356
- p := f .Addr ().Interface ().( * int8 )
356
+ p := ( * int8 )( f .Addr ().UnsafePointer () )
357
357
flags .int8 (p , flagName , shorthand , * p , flagHelp (ft ))
358
358
case reflect .Struct :
359
359
var newprefix string
0 commit comments