Web Development

too many arguments to return is a common error specially when you are new to Go Lang. This is caused by not adding a return type when creating functions.

Error causing Code

package main

import "fmt"

func add(x, y int) {
  return x + y
}

func main() {
  first := 100
  second := 200

  added := add(first, second)
  fmt.Println("", added)
}

Output

$ go run func.go 
# command-line-arguments
./func.go:6: too many arguments to return
./func.go:14: add(first, second) used as value

Fix

func add(x, y int) {
  return x + y
}

should be

func add(x, y int) int {
  return x + y
}

Output

$ go run func.go 
 300