如何为Go服务器设置TLS密码?

I'm currently using the following listen and serve command to run a secure websocket/file server:

http.ListenAndServeTLS(":443", "site.crt","site.key", router)

However, I want to set the cipher to TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 and also set a min SSL/TLS version.

How can I do this?

I think I need to use this Config structure somehow, but I'm not sure how to do this.

You can see an example in secrpc/tls_server.go:

tls.Listen("tcp", addr, &tls.Config{
    Certificates: []tls.Certificate{cert},
    CipherSuites: []uint16{
        tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
        tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
    },
    MinVersion:               tls.VersionTLS12,
    PreferServerCipherSuites: true,
})

See also go/issues/11047 for an example using ListenAndServeTLS: once you have defined your Config, you define your server:

server := &http.Server{Addr: ":4000", Handler: nil, TLSConfig: config}
server.ListenAndServeTLS(tlsPublicKey, tlsPrivateKey)