Package example will not compile for me

trying to compile example code from acme/autocert package with go version OS X go1.9.2 darwin/amd64 and getting: m.HTTPHandler undefined (type *autocert.Manager has no field or method HTTPHandler)
I’m missing something obvious I’m sure? Code below will not compile for me. If I comment out the groutine ( line 17 or so ) I see two methods I expect but miss the HTTPHandler method…

package main

import (


func main() {
	m := &autocert.Manager{
		Cache:      autocert.DirCache("secret-dir"),
		Prompt:     autocert.AcceptTOS,
		HostPolicy: autocert.HostWhitelist(""),
	go http.ListenAndServe(":http", m.HTTPHandler(nil))
	s := &http.Server{
		Addr:      ":https",
		TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
	s.ListenAndServeTLS("", "")

	// debug: list all method names of type = *autocert.Manager

	r := reflect.TypeOf(&autocert.Manager{})
	for i := 0; i < r.NumMethod(); i++ {

	//    prints GetCertificate Listener; yes but expected HTTPHandler also?


HTTPHandler is a new method added in

Update to a newer version of autocert with:

go get -u

BTW, I tested this yesterday when updating my article

that did it!… many thanks and enjoying your article…

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.