I need to return an empty value for a function in golang, my code look something like this.
package main
import (
"fmt"
)
func main(){
for i:=0;i<6;i++{
x,e := test(i)
fmt.Println(i,x,e)
}
}
func test(i int)(r int,err error){
if i%2==0{
return i,nil
}else{
return
}
}
and its output
0 0 <nil> 1 0 <nil> 2 2 <nil> 3 0 <nil> 4 4 <nil> 5 0 <nil>
whereas I want this type of output
0 0 <nil> 1 <nil> <nil> 2 2 <nil> 3 <nil> <nil> 4 4 <nil> 5 <nil> <nil>
How to return empty value in golang?
func test(i *int)(r *int,err error)