How to make a chained call when the golang function has multiple return values?

The

golang function can have multiple return values. Can you specify the number of return values for chained calls, such as the following code:

package main
import "fmt"

func test()(s string,err error){
    return "hello",nil
}
func main(){
    fmt.Println("HelloWorld ",test().s)
}

I hope that after the test () function, ignore err and directly use the first argument, how can it not be called without defining a new variable?
both test () and test (). S are the same error:

. / tempCodeRunnerFile.go:8: multiple-value test () in single-value context

can"t multiple return values be called in chains?

Mar.06,2021

there should be no such operation to


according to your scene.

you can change the return value of test () to the same as the input parameter of fmt.Println, because this function originally supports multiple parameters.

as for multiple return values, I haven't tried chained calls either,


Don't have such a usage scenario. Obviously, it violates the convention
and does not conform to the code specification


.

Yes, multiple return values cannot be called in chains.

if the error returned by this test function is negligible, why do you return an error?


chain calls cannot be realized under multiple return values, thank you!


to be honest, this requirement is a little obsessive-compulsive. If you really have this need, you might as well encapsulate the multiple return values into a struct

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38438-2c0f7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38438-2c0f7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?