The Go Journey
Published in

The Go Journey

Fetch Random Unsplash Images in Your Go Apps

Read the original post for free at https://preslav.me

Perhaps not known to everybody, Unsplash, the free stock photography service, offers its own set of APIs, one of which caught my attention in particular. As part of the project behind my Generative Art in Go book, I needed a way to obtain source image material without looking at it first. By blindly fetching an image, I could guarantee that the final art sketch would be a process of chaos + generative algorithm and not a subject to my decision.

I found the following URL to be a straightforward way to get a random source of beautiful imagery:

I quickly set up the following Go function, which did all the magic for me:

A function for loading random images from Unsplash

Note: Of course, it goes without saying that we must respect Unsplash’s generous offering and not abuse it!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Preslav Rachev

I am a genuinely curious individual on a mission to help digital creators and startups realize their vision. Follow my journey: https://preslav.me