GO script times out

package main

import (






// aliasing type

type Celsius float32

type Fahrenheit float32

func main() {

reader := bufio.NewReader(os.Stdin)

t, _ := reader.ReadString(’\n’)


value, err := strconv.ParseFloat(t, 32)

if err == nil {




// Function to convert celsius to fahrenheit

func toFahrenheit(t Celsius) Fahrenheit {

//var temp Fahrenheit

temp := Fahrenheit((t * 9 / 5) + 32)

return temp


when running this program , it timesout. I am very new to GO . Please suggest

Your code works, but it’s taking longer to execute due to reader.ReadString(‘\n’).
You should improve your code by using ReadLine because ReadString cannot handle the case when the last line of a file doesn’t end with the newline character.

Hope this helps!