本文整理汇总了Golang中context.Context.Searchid方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Searchid方法的具体用法?Golang Context.Searchid怎么用?Golang Context.Searchid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.Searchid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
//.........这里部分代码省略.........
inner_device.OSType = context.OSType_IOS
case jesgoo_interface.OSType_WP:
inner_device.OSType = context.OSType_WP
default:
inner_device.OSType = context.OSType_UNKNOWN
}
}
if len(temp_req.Device.Ids) > 0 {
var device_id context.DeviceID
switch *temp_req.Device.Ids[0].Type {
case jesgoo_interface.DeviceIDType_IMEI:
device_id.DevIDType = context.DeviceIDType_IMEI
case jesgoo_interface.DeviceIDType_MAC:
device_id.DevIDType = context.DeviceIDType_MAC
case jesgoo_interface.DeviceIDType_IDFA:
device_id.DevIDType = context.DeviceIDType_IDFA
default:
device_id.DevIDType = context.DeviceIDType_IMEI
}
device_id.ID = string(temp_req.Device.Ids[0].Id)
inner_device.DevID = append(inner_device.DevID, device_id)
}
}
//network
inner_network := &inner_req.Network
if temp_req.Network != nil {
if temp_req.Network.Ip != nil {
inner_network.Ip = *temp_req.Network.Ip
}
if temp_req.Network.Type != nil {
switch *temp_req.Network.Type {
case jesgoo_interface.NetworkType_WIFI:
inner_network.NetworkType = context.NetworkType_WIFI
case jesgoo_interface.NetworkType_CELLULAR_UNKNOWN:
inner_network.NetworkType = context.NetworkType_UNKNOWN
case jesgoo_interface.NetworkType_CELLULAR_2G:
inner_network.NetworkType = context.NetworkType_2G
case jesgoo_interface.NetworkType_CELLULAR_3G:
inner_network.NetworkType = context.NetworkType_3G
case jesgoo_interface.NetworkType_CELLULAR_4G:
inner_network.NetworkType = context.NetworkType_4G
default:
inner_network.NetworkType = context.NetworkType_UNKNOWN
}
}
}
//adslot
if len(temp_req.Adslots) > 0 {
inner_adslot := &inner_req.AdSlot
temp_adslot := *temp_req.Adslots[0]
if temp_adslot.Id != nil {
inner_adslot.Slotid = *temp_adslot.Id
} else {
inner_adslot.Slotid = "0"
}
if temp_adslot.Type != nil {
switch *temp_adslot.Type {
case jesgoo_interface.AdSlotType_BANNER:
inner_adslot.AdSlotType = context.AdSlotType_BANNER
case jesgoo_interface.AdSlotType_OFFERWALL:
inner_adslot.AdSlotType = context.AdSlotType_OFFERWALL
case jesgoo_interface.AdSlotType_RECOMMEND:
inner_adslot.AdSlotType = context.AdSlotType_RECOMMEND
case jesgoo_interface.AdSlotType_INTERSTITIAL:
inner_adslot.AdSlotType = context.AdSlotType_INSERT
case jesgoo_interface.AdSlotType_REALTIME_SPLASH:
inner_adslot.AdSlotType = context.AdSlotType_INITIALIZATION
default:
inner_adslot.AdSlotType = context.AdSlotType_BANNER
}
} else {
inner_adslot.AdSlotType = context.AdSlotType_BANNER
}
if temp_adslot.Capacity != nil {
inner_adslot.Capacity = *temp_adslot.Capacity
} else {
inner_adslot.Capacity = 1
}
} else {
err = errors.New("no adslot in request")
return
}
//is debug request
inner_data.Req.Debug = false
if temp_req.Debug != nil {
inner_data.Req.Debug = *temp_req.Debug
}
//searchid
if len(inner_data.Req.Device.DevID) > 0 {
inner_data.Searchid = utils.GenSearchid(inner_data.Req.Device.DevID[0].ID)
} else {
inner_data.Searchid = utils.GenSearchid("default")
}
return
}
示例2: parse
//.........这里部分代码省略.........
case 3:
inner_device.OSType = context.OSType_WP
default:
inner_device.OSType = context.OSType_UNKNOWN
}
inner_device.OSVersion.Major = temp_req_device.Os_version.Major
inner_device.OSVersion.Minor = temp_req_device.Os_version.Minor
inner_device.OSVersion.Micro = temp_req_device.Os_version.Micro
inner_device.Brand = temp_req_device.Brand
inner_device.Model = temp_req_device.Model
if temp_req_device.Ids != nil {
var device_id DeviceId
for i := 0; i < len(temp_req_device.Ids); i++ {
device_id = temp_req_device.Ids[i]
var inner_device_id context.DeviceID
switch device_id.Type {
case 1:
inner_device_id.DevIDType = context.DeviceIDType_IMEI
case 2:
inner_device_id.DevIDType = context.DeviceIDType_MAC
case 3:
inner_device_id.DevIDType = context.DeviceIDType_IDFA
case 4:
inner_device_id.DevIDType = context.DeviceIDType_AAID
default:
inner_device_id.DevIDType = context.DeviceIDType_IMEI
}
inner_device_id.ID = device_id.Id
inner_device.DevID = append(inner_device.DevID, inner_device_id)
}
}
//network
temp_req_network := &temp_req.Network
if temp_req_network == nil {
utils.DebugLog.Write("request has no network")
} else {
inner_network := &inner_data.Req.Network
if len(temp_req_network.Ip) > 6 {
inner_network.Ip = temp_req_network.Ip
utils.DebugLog.Write("client ip is %s", temp_req_network.Ip)
}
switch temp_req_network.Type {
case 1:
inner_network.NetworkType = context.NetworkType_WIFI
case 2:
inner_network.NetworkType = context.NetworkType_UNKNOWN
case 3:
inner_network.NetworkType = context.NetworkType_2G
case 4:
inner_network.NetworkType = context.NetworkType_3G
case 5:
inner_network.NetworkType = context.NetworkType_4G
}
}
//adslot
if len(temp_req.Adslots) > 0 {
temp_req_adslot := &temp_req.Adslots[0]
inner_adslot := &inner_data.Req.AdSlot
inner_adslot.Slotid = temp_req_adslot.Id
switch temp_req_adslot.Type {
case 1:
inner_adslot.AdSlotType = context.AdSlotType_BANNER
case 2:
inner_adslot.AdSlotType = context.AdSlotType_OFFERWALL
case 3:
inner_adslot.AdSlotType = context.AdSlotType_RECOMMEND
case 4:
inner_adslot.AdSlotType = context.AdSlotType_INITIALIZATION
case 5:
inner_adslot.AdSlotType = context.AdSlotType_INSERT
default:
inner_adslot.AdSlotType = context.AdSlotType_BANNER
}
inner_adslot.Size.Width = temp_req_adslot.Size.Width
inner_adslot.Size.Height = temp_req_adslot.Size.Height
if temp_req_adslot.Capacity != 0 {
inner_adslot.Capacity = temp_req_adslot.Capacity
} else {
inner_adslot.Capacity = 1
}
} else {
err = errors.New("no adslot info in request")
return
}
inner_data.Req.Debug = temp_req.Debug
utils.DebugLog.Write("get debug flag [%d]", inner_data.Req.Debug)
//searchid
if len(inner_data.Req.Device.DevID) > 0 {
inner_data.Searchid = utils.GenSearchid(inner_data.Req.Device.DevID[0].ID)
} else {
inner_data.Searchid = utils.GenSearchid("default")
}
}
return
}