You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: health_check.go
    path of file: ./repos/bfe/bfe_balance/backend
    
    the code of the file until where you have to start completion: // Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// health check for backend

package backend

import (
	"fmt"
	"net"
	"net/http"
	"strings"
	"time"
)

import (
	"github.com/baidu/go-lib/log"
)

import (
	"github.com
    
func check(backend *BfeBackend, cluster string) {
	log.Logger.Info("start healthcheck for %s", backend.Name)

	// backend close chan
	c := backend.CloseChan()

loop:
	for {
		select {
		case <-c: // backend deleted
			break loop
		default:
		}

		// get the latest conf to do health check
		checkConf := getCheckConf(cluster)
		if checkConf == nil {
			// never come here
			time.Sleep(time.Second)
			continue
		}
		checkInterval := time.Duration(*checkConf.CheckInterval) * time.Millisecond

		// health check
		if ok, err := CheckConnect(backend, checkConf); !ok {
			backend.ResetSuccNum()
			if bfe_debug.DebugHealthCheck {
				log.Logger.Debug("backend %s still not avail (check failure: %s)", backend.Name, err)
			}
			time.Sleep(checkInterval)
			continue
		}

		// check whether backend becomes available
		backend.AddSuccNum()
		if !backend.CheckAvail(*checkConf.SuccNum) {
			if bfe_debug.DebugHealthCheck {
				log.Logger.Debug("backend %s still not avail (check success, waiting for more checks)", backend.Name)
			}
			time.Sleep(checkInterval)
			continue
		}

		log.Logger.Info("backend %s back to Normal", backend.Name)
		backend.SetRestart(true)
		backend.SetAvail(true)
		break loop
	}
}