gRPC client in Go

Create a gRPC-compatible HTTP/2 client in Go using http2.Transport or standard http.Client with TLS.

Use the http2.Transport type from golang.org/x/net/http2 to create a client that speaks HTTP/2 directly, or configure a standard http.Transport to enable HTTP/2 over TLS. For explicit HTTP/2 client control, instantiate http2.Transport and use it with http.Client.

import (
	"net/http"
	"golang.org/x/net/http2"
)

func main() {
	tr := &http2.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	client := &http.Client{Transport: tr}
	resp, err := client.Get("https://example.com")
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()
}

For standard HTTPS clients in Go 1.6+, HTTP/2 is enabled automatically if the server supports ALPN; no extra code is needed.