Too many return values

I am a newbie gopher and I have exhausted myself trying to solve the “too many return values” mystery. See code below. Any help much appreciated. (go version go1.19 windows/amd64 Windows 10)

\\package main

import “fmt”

func main() {

func Hellx() {
abc := “hello from depx”
return abc

./prog.go:6:14: Hellx() (no value) used as value
./prog.go:11:9: too many return values
have (string)
want ()

Go build failed.

The Hellx function does not have a declared return type, still you try to return a value. As abc seems to be string, the correct would be to use the string return type.

duh! Like I said, “I’m a newbie.” Thanks for taking the time to make this a “teaching moment.” :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.