func getIndex(client flickr.Client, userInfo views.UserInfo, _ string, page, pageSize int) (views.PhotosCtx, error) { resp, err := client.PublicPhotos(userInfo.Id, pageSize, page) if err != nil { return views.PhotosCtx{}, err } ctx := views.PhotosCtx{ Title: fmt.Sprintf("ihkh : %s", userInfo.UserName), Photos: []views.Photo{}, UserInfo: userInfo, } if resp.Photos.Page > 1 { ctx.PrevPage = fmt.Sprintf("/%d", resp.Photos.Page-1) } if resp.Photos.Page != resp.Photos.Pages { ctx.NextPage = fmt.Sprintf("/%d", 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 }