title: consul & connect undefined: freeport.GetOne
body: <p>I copied a piece of code from <a href="https://www.consul.io/docs/connect/native/go" rel="nofollow noreferrer"><code>consul doc</code></a> to <code>main.go</code> file</p>
  <p><strong>main.go</strong></p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;fmt&quot;
      &quot;io/ioutil&quot;
  
      &quot;github.com/hashicorp/consul/api&quot;
      &quot;github.com/hashicorp/consul/connect&quot;
  )
  
  func main() {
  
      // Create a Consul API client
      client, _ := api.NewClient(api.DefaultConfig())
  
      // Create an instance representing this service. &quot;my-service&quot; is the
      // name of _this_ service. The service should be cleaned up via Close.
      svc, _ := connect.NewService(&quot;my-service&quot;, client)
      defer svc.Close()
  
      // Get an HTTP client
      httpClient := svc.HTTPClient()
  
      // Perform a request, then use the standard response
      resp, _ := httpClient.Get(&quot;http://web.service.consul/autoCode/getColumn&quot;)
  
      buf, _ := ioutil.ReadAll(resp.Body)
  
      fmt.Println(string(buf))
  }
  </code></pre>
  <p>then execute below steps in sequence</p>
  <pre class="lang-golang prettyprint-override"><code>go mod init
  go get -u -v github.com/hashicorp/consul/api
  go get -u -v github.com/hashicorp/consul/connect
  go mod tidy
  go test
  </code></pre>
  <p>Output error:</p>
  <blockquote>
  <p><strong>\go\pkg\mod\github.com\hashicorp\consul@v1.11.4\connect\testing.go:112:42: undefined: freeport.GetOne</strong></p>
  </blockquote>
  <p>OS: win10
  Go version:1.17.7</p>
  <p>Can anyone help me solve this question.  THANKS.</p>