http urls monitor.

convert_types.go 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. package swag
  2. import "time"
  3. // This file was taken from the aws go sdk
  4. // String returns a pointer to of the string value passed in.
  5. func String(v string) *string {
  6. return &v
  7. }
  8. // StringValue returns the value of the string pointer passed in or
  9. // "" if the pointer is nil.
  10. func StringValue(v *string) string {
  11. if v != nil {
  12. return *v
  13. }
  14. return ""
  15. }
  16. // StringSlice converts a slice of string values into a slice of
  17. // string pointers
  18. func StringSlice(src []string) []*string {
  19. dst := make([]*string, len(src))
  20. for i := 0; i < len(src); i++ {
  21. dst[i] = &(src[i])
  22. }
  23. return dst
  24. }
  25. // StringValueSlice converts a slice of string pointers into a slice of
  26. // string values
  27. func StringValueSlice(src []*string) []string {
  28. dst := make([]string, len(src))
  29. for i := 0; i < len(src); i++ {
  30. if src[i] != nil {
  31. dst[i] = *(src[i])
  32. }
  33. }
  34. return dst
  35. }
  36. // StringMap converts a string map of string values into a string
  37. // map of string pointers
  38. func StringMap(src map[string]string) map[string]*string {
  39. dst := make(map[string]*string)
  40. for k, val := range src {
  41. v := val
  42. dst[k] = &v
  43. }
  44. return dst
  45. }
  46. // StringValueMap converts a string map of string pointers into a string
  47. // map of string values
  48. func StringValueMap(src map[string]*string) map[string]string {
  49. dst := make(map[string]string)
  50. for k, val := range src {
  51. if val != nil {
  52. dst[k] = *val
  53. }
  54. }
  55. return dst
  56. }
  57. // Bool returns a pointer to of the bool value passed in.
  58. func Bool(v bool) *bool {
  59. return &v
  60. }
  61. // BoolValue returns the value of the bool pointer passed in or
  62. // false if the pointer is nil.
  63. func BoolValue(v *bool) bool {
  64. if v != nil {
  65. return *v
  66. }
  67. return false
  68. }
  69. // BoolSlice converts a slice of bool values into a slice of
  70. // bool pointers
  71. func BoolSlice(src []bool) []*bool {
  72. dst := make([]*bool, len(src))
  73. for i := 0; i < len(src); i++ {
  74. dst[i] = &(src[i])
  75. }
  76. return dst
  77. }
  78. // BoolValueSlice converts a slice of bool pointers into a slice of
  79. // bool values
  80. func BoolValueSlice(src []*bool) []bool {
  81. dst := make([]bool, len(src))
  82. for i := 0; i < len(src); i++ {
  83. if src[i] != nil {
  84. dst[i] = *(src[i])
  85. }
  86. }
  87. return dst
  88. }
  89. // BoolMap converts a string map of bool values into a string
  90. // map of bool pointers
  91. func BoolMap(src map[string]bool) map[string]*bool {
  92. dst := make(map[string]*bool)
  93. for k, val := range src {
  94. v := val
  95. dst[k] = &v
  96. }
  97. return dst
  98. }
  99. // BoolValueMap converts a string map of bool pointers into a string
  100. // map of bool values
  101. func BoolValueMap(src map[string]*bool) map[string]bool {
  102. dst := make(map[string]bool)
  103. for k, val := range src {
  104. if val != nil {
  105. dst[k] = *val
  106. }
  107. }
  108. return dst
  109. }
  110. // Int returns a pointer to of the int value passed in.
  111. func Int(v int) *int {
  112. return &v
  113. }
  114. // IntValue returns the value of the int pointer passed in or
  115. // 0 if the pointer is nil.
  116. func IntValue(v *int) int {
  117. if v != nil {
  118. return *v
  119. }
  120. return 0
  121. }
  122. // IntSlice converts a slice of int values into a slice of
  123. // int pointers
  124. func IntSlice(src []int) []*int {
  125. dst := make([]*int, len(src))
  126. for i := 0; i < len(src); i++ {
  127. dst[i] = &(src[i])
  128. }
  129. return dst
  130. }
  131. // IntValueSlice converts a slice of int pointers into a slice of
  132. // int values
  133. func IntValueSlice(src []*int) []int {
  134. dst := make([]int, len(src))
  135. for i := 0; i < len(src); i++ {
  136. if src[i] != nil {
  137. dst[i] = *(src[i])
  138. }
  139. }
  140. return dst
  141. }
  142. // IntMap converts a string map of int values into a string
  143. // map of int pointers
  144. func IntMap(src map[string]int) map[string]*int {
  145. dst := make(map[string]*int)
  146. for k, val := range src {
  147. v := val
  148. dst[k] = &v
  149. }
  150. return dst
  151. }
  152. // IntValueMap converts a string map of int pointers into a string
  153. // map of int values
  154. func IntValueMap(src map[string]*int) map[string]int {
  155. dst := make(map[string]int)
  156. for k, val := range src {
  157. if val != nil {
  158. dst[k] = *val
  159. }
  160. }
  161. return dst
  162. }
  163. // Int32 returns a pointer to of the int64 value passed in.
  164. func Int32(v int32) *int32 {
  165. return &v
  166. }
  167. // Int32Value returns the value of the int64 pointer passed in or
  168. // 0 if the pointer is nil.
  169. func Int32Value(v *int32) int32 {
  170. if v != nil {
  171. return *v
  172. }
  173. return 0
  174. }
  175. // Int32Slice converts a slice of int64 values into a slice of
  176. // int32 pointers
  177. func Int32Slice(src []int32) []*int32 {
  178. dst := make([]*int32, len(src))
  179. for i := 0; i < len(src); i++ {
  180. dst[i] = &(src[i])
  181. }
  182. return dst
  183. }
  184. // Int32ValueSlice converts a slice of int32 pointers into a slice of
  185. // int32 values
  186. func Int32ValueSlice(src []*int32) []int32 {
  187. dst := make([]int32, len(src))
  188. for i := 0; i < len(src); i++ {
  189. if src[i] != nil {
  190. dst[i] = *(src[i])
  191. }
  192. }
  193. return dst
  194. }
  195. // Int32Map converts a string map of int32 values into a string
  196. // map of int32 pointers
  197. func Int32Map(src map[string]int32) map[string]*int32 {
  198. dst := make(map[string]*int32)
  199. for k, val := range src {
  200. v := val
  201. dst[k] = &v
  202. }
  203. return dst
  204. }
  205. // Int32ValueMap converts a string map of int32 pointers into a string
  206. // map of int32 values
  207. func Int32ValueMap(src map[string]*int32) map[string]int32 {
  208. dst := make(map[string]int32)
  209. for k, val := range src {
  210. if val != nil {
  211. dst[k] = *val
  212. }
  213. }
  214. return dst
  215. }
  216. // Int64 returns a pointer to of the int64 value passed in.
  217. func Int64(v int64) *int64 {
  218. return &v
  219. }
  220. // Int64Value returns the value of the int64 pointer passed in or
  221. // 0 if the pointer is nil.
  222. func Int64Value(v *int64) int64 {
  223. if v != nil {
  224. return *v
  225. }
  226. return 0
  227. }
  228. // Int64Slice converts a slice of int64 values into a slice of
  229. // int64 pointers
  230. func Int64Slice(src []int64) []*int64 {
  231. dst := make([]*int64, len(src))
  232. for i := 0; i < len(src); i++ {
  233. dst[i] = &(src[i])
  234. }
  235. return dst
  236. }
  237. // Int64ValueSlice converts a slice of int64 pointers into a slice of
  238. // int64 values
  239. func Int64ValueSlice(src []*int64) []int64 {
  240. dst := make([]int64, len(src))
  241. for i := 0; i < len(src); i++ {
  242. if src[i] != nil {
  243. dst[i] = *(src[i])
  244. }
  245. }
  246. return dst
  247. }
  248. // Int64Map converts a string map of int64 values into a string
  249. // map of int64 pointers
  250. func Int64Map(src map[string]int64) map[string]*int64 {
  251. dst := make(map[string]*int64)
  252. for k, val := range src {
  253. v := val
  254. dst[k] = &v
  255. }
  256. return dst
  257. }
  258. // Int64ValueMap converts a string map of int64 pointers into a string
  259. // map of int64 values
  260. func Int64ValueMap(src map[string]*int64) map[string]int64 {
  261. dst := make(map[string]int64)
  262. for k, val := range src {
  263. if val != nil {
  264. dst[k] = *val
  265. }
  266. }
  267. return dst
  268. }
  269. // Uint returns a pouinter to of the uint value passed in.
  270. func Uint(v uint) *uint {
  271. return &v
  272. }
  273. // UintValue returns the value of the uint pouinter passed in or
  274. // 0 if the pouinter is nil.
  275. func UintValue(v *uint) uint {
  276. if v != nil {
  277. return *v
  278. }
  279. return 0
  280. }
  281. // UintSlice converts a slice of uint values uinto a slice of
  282. // uint pouinters
  283. func UintSlice(src []uint) []*uint {
  284. dst := make([]*uint, len(src))
  285. for i := 0; i < len(src); i++ {
  286. dst[i] = &(src[i])
  287. }
  288. return dst
  289. }
  290. // UintValueSlice converts a slice of uint pouinters uinto a slice of
  291. // uint values
  292. func UintValueSlice(src []*uint) []uint {
  293. dst := make([]uint, len(src))
  294. for i := 0; i < len(src); i++ {
  295. if src[i] != nil {
  296. dst[i] = *(src[i])
  297. }
  298. }
  299. return dst
  300. }
  301. // UintMap converts a string map of uint values uinto a string
  302. // map of uint pouinters
  303. func UintMap(src map[string]uint) map[string]*uint {
  304. dst := make(map[string]*uint)
  305. for k, val := range src {
  306. v := val
  307. dst[k] = &v
  308. }
  309. return dst
  310. }
  311. // UintValueMap converts a string map of uint pouinters uinto a string
  312. // map of uint values
  313. func UintValueMap(src map[string]*uint) map[string]uint {
  314. dst := make(map[string]uint)
  315. for k, val := range src {
  316. if val != nil {
  317. dst[k] = *val
  318. }
  319. }
  320. return dst
  321. }
  322. // Uint32 returns a pouinter to of the uint64 value passed in.
  323. func Uint32(v uint32) *uint32 {
  324. return &v
  325. }
  326. // Uint32Value returns the value of the uint64 pouinter passed in or
  327. // 0 if the pouinter is nil.
  328. func Uint32Value(v *uint32) uint32 {
  329. if v != nil {
  330. return *v
  331. }
  332. return 0
  333. }
  334. // Uint32Slice converts a slice of uint64 values uinto a slice of
  335. // uint32 pouinters
  336. func Uint32Slice(src []uint32) []*uint32 {
  337. dst := make([]*uint32, len(src))
  338. for i := 0; i < len(src); i++ {
  339. dst[i] = &(src[i])
  340. }
  341. return dst
  342. }
  343. // Uint32ValueSlice converts a slice of uint32 pouinters uinto a slice of
  344. // uint32 values
  345. func Uint32ValueSlice(src []*uint32) []uint32 {
  346. dst := make([]uint32, len(src))
  347. for i := 0; i < len(src); i++ {
  348. if src[i] != nil {
  349. dst[i] = *(src[i])
  350. }
  351. }
  352. return dst
  353. }
  354. // Uint32Map converts a string map of uint32 values uinto a string
  355. // map of uint32 pouinters
  356. func Uint32Map(src map[string]uint32) map[string]*uint32 {
  357. dst := make(map[string]*uint32)
  358. for k, val := range src {
  359. v := val
  360. dst[k] = &v
  361. }
  362. return dst
  363. }
  364. // Uint32ValueMap converts a string map of uint32 pouinters uinto a string
  365. // map of uint32 values
  366. func Uint32ValueMap(src map[string]*uint32) map[string]uint32 {
  367. dst := make(map[string]uint32)
  368. for k, val := range src {
  369. if val != nil {
  370. dst[k] = *val
  371. }
  372. }
  373. return dst
  374. }
  375. // Uint64 returns a pouinter to of the uint64 value passed in.
  376. func Uint64(v uint64) *uint64 {
  377. return &v
  378. }
  379. // Uint64Value returns the value of the uint64 pouinter passed in or
  380. // 0 if the pouinter is nil.
  381. func Uint64Value(v *uint64) uint64 {
  382. if v != nil {
  383. return *v
  384. }
  385. return 0
  386. }
  387. // Uint64Slice converts a slice of uint64 values uinto a slice of
  388. // uint64 pouinters
  389. func Uint64Slice(src []uint64) []*uint64 {
  390. dst := make([]*uint64, len(src))
  391. for i := 0; i < len(src); i++ {
  392. dst[i] = &(src[i])
  393. }
  394. return dst
  395. }
  396. // Uint64ValueSlice converts a slice of uint64 pouinters uinto a slice of
  397. // uint64 values
  398. func Uint64ValueSlice(src []*uint64) []uint64 {
  399. dst := make([]uint64, len(src))
  400. for i := 0; i < len(src); i++ {
  401. if src[i] != nil {
  402. dst[i] = *(src[i])
  403. }
  404. }
  405. return dst
  406. }
  407. // Uint64Map converts a string map of uint64 values uinto a string
  408. // map of uint64 pouinters
  409. func Uint64Map(src map[string]uint64) map[string]*uint64 {
  410. dst := make(map[string]*uint64)
  411. for k, val := range src {
  412. v := val
  413. dst[k] = &v
  414. }
  415. return dst
  416. }
  417. // Uint64ValueMap converts a string map of uint64 pouinters uinto a string
  418. // map of uint64 values
  419. func Uint64ValueMap(src map[string]*uint64) map[string]uint64 {
  420. dst := make(map[string]uint64)
  421. for k, val := range src {
  422. if val != nil {
  423. dst[k] = *val
  424. }
  425. }
  426. return dst
  427. }
  428. // Float64 returns a pointer to of the float64 value passed in.
  429. func Float64(v float64) *float64 {
  430. return &v
  431. }
  432. // Float64Value returns the value of the float64 pointer passed in or
  433. // 0 if the pointer is nil.
  434. func Float64Value(v *float64) float64 {
  435. if v != nil {
  436. return *v
  437. }
  438. return 0
  439. }
  440. // Float64Slice converts a slice of float64 values into a slice of
  441. // float64 pointers
  442. func Float64Slice(src []float64) []*float64 {
  443. dst := make([]*float64, len(src))
  444. for i := 0; i < len(src); i++ {
  445. dst[i] = &(src[i])
  446. }
  447. return dst
  448. }
  449. // Float64ValueSlice converts a slice of float64 pointers into a slice of
  450. // float64 values
  451. func Float64ValueSlice(src []*float64) []float64 {
  452. dst := make([]float64, len(src))
  453. for i := 0; i < len(src); i++ {
  454. if src[i] != nil {
  455. dst[i] = *(src[i])
  456. }
  457. }
  458. return dst
  459. }
  460. // Float64Map converts a string map of float64 values into a string
  461. // map of float64 pointers
  462. func Float64Map(src map[string]float64) map[string]*float64 {
  463. dst := make(map[string]*float64)
  464. for k, val := range src {
  465. v := val
  466. dst[k] = &v
  467. }
  468. return dst
  469. }
  470. // Float64ValueMap converts a string map of float64 pointers into a string
  471. // map of float64 values
  472. func Float64ValueMap(src map[string]*float64) map[string]float64 {
  473. dst := make(map[string]float64)
  474. for k, val := range src {
  475. if val != nil {
  476. dst[k] = *val
  477. }
  478. }
  479. return dst
  480. }
  481. // Time returns a pointer to of the time.Time value passed in.
  482. func Time(v time.Time) *time.Time {
  483. return &v
  484. }
  485. // TimeValue returns the value of the time.Time pointer passed in or
  486. // time.Time{} if the pointer is nil.
  487. func TimeValue(v *time.Time) time.Time {
  488. if v != nil {
  489. return *v
  490. }
  491. return time.Time{}
  492. }
  493. // TimeSlice converts a slice of time.Time values into a slice of
  494. // time.Time pointers
  495. func TimeSlice(src []time.Time) []*time.Time {
  496. dst := make([]*time.Time, len(src))
  497. for i := 0; i < len(src); i++ {
  498. dst[i] = &(src[i])
  499. }
  500. return dst
  501. }
  502. // TimeValueSlice converts a slice of time.Time pointers into a slice of
  503. // time.Time values
  504. func TimeValueSlice(src []*time.Time) []time.Time {
  505. dst := make([]time.Time, len(src))
  506. for i := 0; i < len(src); i++ {
  507. if src[i] != nil {
  508. dst[i] = *(src[i])
  509. }
  510. }
  511. return dst
  512. }
  513. // TimeMap converts a string map of time.Time values into a string
  514. // map of time.Time pointers
  515. func TimeMap(src map[string]time.Time) map[string]*time.Time {
  516. dst := make(map[string]*time.Time)
  517. for k, val := range src {
  518. v := val
  519. dst[k] = &v
  520. }
  521. return dst
  522. }
  523. // TimeValueMap converts a string map of time.Time pointers into a string
  524. // map of time.Time values
  525. func TimeValueMap(src map[string]*time.Time) map[string]time.Time {
  526. dst := make(map[string]time.Time)
  527. for k, val := range src {
  528. if val != nil {
  529. dst[k] = *val
  530. }
  531. }
  532. return dst
  533. }