本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6KB

  1. // Copyright (c) 2018 Couchbase, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package size
  15. import (
  16. "reflect"
  17. )
  18. func init() {
  19. var b bool
  20. SizeOfBool = int(reflect.TypeOf(b).Size())
  21. var f32 float32
  22. SizeOfFloat32 = int(reflect.TypeOf(f32).Size())
  23. var f64 float64
  24. SizeOfFloat64 = int(reflect.TypeOf(f64).Size())
  25. var i int
  26. SizeOfInt = int(reflect.TypeOf(i).Size())
  27. var m map[int]int
  28. SizeOfMap = int(reflect.TypeOf(m).Size())
  29. var ptr *int
  30. SizeOfPtr = int(reflect.TypeOf(ptr).Size())
  31. var slice []int
  32. SizeOfSlice = int(reflect.TypeOf(slice).Size())
  33. var str string
  34. SizeOfString = int(reflect.TypeOf(str).Size())
  35. var u8 uint8
  36. SizeOfUint8 = int(reflect.TypeOf(u8).Size())
  37. var u16 uint16
  38. SizeOfUint16 = int(reflect.TypeOf(u16).Size())
  39. var u32 uint32
  40. SizeOfUint32 = int(reflect.TypeOf(u32).Size())
  41. var u64 uint64
  42. SizeOfUint64 = int(reflect.TypeOf(u64).Size())
  43. }
  44. var SizeOfBool int
  45. var SizeOfFloat32 int
  46. var SizeOfFloat64 int
  47. var SizeOfInt int
  48. var SizeOfMap int
  49. var SizeOfPtr int
  50. var SizeOfSlice int
  51. var SizeOfString int
  52. var SizeOfUint8 int
  53. var SizeOfUint16 int
  54. var SizeOfUint32 int
  55. var SizeOfUint64 int
上海开阖软件有限公司 沪ICP备12045867号-1