I make this code for learning:-
package main
import (
"fmt"
"strconv"
)
func main() {
for {
name := ""
fmt.Print("Enter : ")
fmt.Scanf("%s", &name)
b1, _ := strconv.ParseBool(name)
fmt.Printf("%T, %v\n", b1, b1)
}
}
output:
Enter : True
bool, true
Enter : bool, false
Enter :
why there is extra "Enter : bool, false" line?
>Solution :
I assume you’re using some IDE.
sometimes they mess up the console output, try to run directly from native terminal instead. Or use vscode.
