func getTag(client flickr.Client, userInfo views.UserInfo, tag string, page, pageSize int) (views.PhotosCtx, error) { resp, err := client.Tag(userInfo.Id, tag, pageSize, page) if err != nil { return views.PhotosCtx{}, err } ctx := views.PhotosCtx{ Title: fmt.Sprintf("ihkh : %s : %s", userInfo.UserName, tag), Photos: []views.Photo{}, UserInfo: userInfo, } if resp.Photos.Page > 1 { ctx.PrevPage = fmt.Sprintf("/tags/%s/%d", tag, resp.Photos.Page-1) } if resp.Photos.Page != resp.Photos.Pages { ctx.NextPage = fmt.Sprintf("/tags/%s/%d", tag, resp.Photos.Page+1) } for _, photo := range resp.Photos.Photo { ctx.Photos = append(ctx.Photos, views.Photo{ Id: photo.Id, Src: photo.Url, Width: photo.Width, Height: photo.Height, }) } return ctx, nil }