在Go中替换Windows换行符

Trying to replace windows line ending using strings.Replace:

package main

import (
    "fmt"
    "strings"
)

var hw string = "hello
world"

func main() {
    fmt.Println(hw)
    strings.Replace(hw, "
", " ", -1)
    fmt.Println(hw)
}

I suppose it is something very simple I am missing but not sure why the above does not work.

You are just printing the same string value twice. strings.Replace() returns you the result which you just discard (you don't do anything with it). Store the result e.g. to the same variable:

fmt.Println(hw)
hw = strings.Replace(hw, "
", " ", -1)
fmt.Println(hw)

Output will be (try it on the Go Playground):

hello
world
hello world