Server-Side Scripting/Strings and Files/Go

routes/lesson5.go
"   return result }

func processLine(line string) string { // skip heading index := strings.Index(line, "Country,MaximumTemperature") if index >= 0 { return "" }

start := strings.Index(line, ",") end := strings.Index(line, " °C") if start < 0 || end < 0 { return "Invalid file format: " + line + " " }

celsius, err := strconv.ParseFloat(line[start + 1:end], 64) if err != nil { return err.Error }

fahrenheit := celsius * 9 / 5 + 32 result := " " + strconv.FormatFloat(celsius, 'f', 1, 64) + " " result += " " + strconv.FormatFloat(fahrenheit, 'f', 1, 64) + " "

return result }

Try It
See ../../Routes and Templates/Go to create a test environment.