Golang in sixty seconds — return multiple values from functions

Industrial revolution vector created by jcompwww.freepik.com

If you’re not familiar with functions, please read this article first.

Golang allows you to return multiple values from a function. Typically this is used for error handling, so you might see a function like this:

func getSecondItem(items []string) (string, error) {
if len(items) < 2 {
return "", errors.New("Too short")
}…

--

--

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
Richard Bell

Richard Bell

445 Followers

Father to a beautiful baby girl | Husband to a generous wife | Lead Software Engineer | Hobby collector | Support me at ko-fi.com/richardtbell