• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
July 08, 2022 |1.9K Views

Multiple Return Values and Go Formatting Tools

  Share   Like
Description
Discussion

In Golang, we can return multiple values at a time from a single function. Multiple return values can be achieved by changing the return type of the function in the function signature.

Syntax :

func value( ) ( int , int ) { 
return 1 , 0 ; 


The (int, int) in this function signature explains that the return type is two integers. Thus we have to use multiple assignments while calling this function. This feature is also used to return both results and error from a function. If you want a subset of the returned values, use the blank identifier _.

 

Multiple Return Values and Go Formatting Tools : https://www.geeksforgeeks.org/golang-program-that-uses-multiple-return-values/