Original post

Hey,

I am trying to create a program which opens a file, and if in the file a line starts “1” then it call it “func1” and if line starts with “2” then it calls “func2”, but for some reason, my case 1 is working fine but I am getting error for my case 2.

The error I am getting is .main.:34:15: assignment mismatch: 2 variables but Package.pack2 returns 3 values

Can someone plz help me with this:

package main

import (
“bufio”
//“fmt”
package “local/package”
“log”
“os”
)

func main() {
file, err := os.Open(“file path”)

if err != nil {
	log.Fatalf("failed opening file: %s", err)
}

scanner := bufio.NewScanner(file)
var 0 package.pack1 
var 1 package.pack2
var 2 package.pack2
var 3 package.pack2

for scanner.Scan() {
	line := scanner.Text()
	switch line[0] {
	case '1':
		{
			0, err = package.func1(line)
			log.Fatal("The file has 1", 0)
		}
	case '2':
		{
			1, err = package.func2(line)
			log.Fatal("The file has 2", 1)
		
			2, err = package.func2(line)
			log.Fatal("The file has 3", 2)

			3, err = package.func2(line)
			log.Fatal("The file has 2", 3)


		}
	}
}

file.Close()