阿里云sdk不支持一次性请求太多,所以我们需要限制每次请求最大1000条,此代码无任何参考意义。仅做记录
func VulList(hole_type string) ([]*sas20181203.DescribeVulListResponseBodyVulRecords, error) {
pageSize := 20
allItems := make([]*sas20181203.DescribeVulListResponseBodyVulRecords, 0)
info, err := RequestVulList(hole_type, int32(pageSize), 1)
if err != nil {
return nil, err
}
if info == nil || info.Body.VulRecords == nil {
return allItems, nil
}
allItems = append(allItems, info.Body.VulRecords...)
totalCount := int(*info.Body.TotalCount)
if totalCount > 20 {
allItems = allItems[20:]
pageSize = 1000
}
for len(allItems) < totalCount {
currentPage := len(allItems)/pageSize + 1
info, err := RequestVulList(hole_type, int32(pageSize), int32(currentPage))
if err != nil {
return nil, err
}
if info == nil || info.Body.VulRecords == nil {
break
}
allItems = append(allItems, info.Body.VulRecords...)
fmt.Println("allItems: ", len(allItems), totalCount)
}
return allItems, nil
}