GO Lang, Error While taking an input

I was trying for this problem CHEFINSQ
I was able to read in my local machine.
package main
import (
“fmt”
“os”
“bufio”
// “strconv”
// “strings”
// “sort”
)
for main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
testCaseNo := scanner.Text()
testInputs, _ := strconv.Atoi(testCaseNo)
fmt.Println(testInputs)
}

There’s a typo in your code, remove the “for” in front of the main function definition
package main
import (
“fmt”
“os”
“bufio”
// “strconv”
// “strings”
// “sort”
)
main() { //for keyword removed!
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
testCaseNo := scanner.Text()
testInputs, _ := strconv.Atoi(testCaseNo)
fmt.Println(testInputs)
}

1 Like