Question about consul/connect

I copied a piece of code form in to a main. go file.

like this:

package main

import (


func main() {

	// Create a Consul API client
	client, _ := api.NewClient(api.DefaultConfig())

	// Create an instance representing this service. "my-service" is the
	// name of _this_ service. The service should be cleaned up via Close.
	svc, _ := connect.NewService("my-service", client)
	defer svc.Close()

	// Get an HTTP client
	httpClient := svc.HTTPClient()

	// Perform a request, then use the standard response
	resp, _ := httpClient.Get("http://web.service.consul/autoCode/getColumn")

	buf, _ := ioutil.ReadAll(resp.Body)



then execute in sequence

go mod init
go get - u -v
go get -u - v
go mod tidy
go test

out put error:

\go\pkg\mod\\hashicorp\consul@v1.11.4\connect\testing.go:112:42: undefined: freeport.GetOne

OS: win10
Go version:1.17.7

Can anyone help me solve this question. THANKS.