| Conditions | 3 |
| Total Lines | 14 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package fun |
||
| 38 | func GetImage(category string) (*bytes.Buffer, error) { |
||
| 39 | resp, err := http.Get(fmt.Sprintf("https://botimages.realpha.ru/?category=%v", category)) |
||
| 40 | if err != nil { |
||
| 41 | fmt.Printf("Getting image url error: %v", err) |
||
| 42 | return nil, errors.New("getting image url error") |
||
| 43 | } |
||
| 44 | |||
| 45 | buf := new(bytes.Buffer) |
||
| 46 | |||
| 47 | _, err = io.Copy(buf, resp.Body) //png.Encode(buf, resp.Body) |
||
| 48 | if err != nil { |
||
| 49 | fmt.Printf("Map image: %v", err.Error()) |
||
| 50 | } |
||
| 51 | return buf, err |
||
| 52 | } |
||
| 53 |