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: codeowners.go
    path of file: ./repos/cockroach/pkg/internal/codeowners
    
    the code of the file until where you have to start completion: // Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package codeowners

import (
	"bufio"
	"io"
	"os"
	"path/filepath"
	"strings"

	"github.com/cockroachdb/cockroach/pkg/build/bazel"
	"github.com/cockroachdb/cockroach/pkg/internal/reporoot"
	"github.com/cockroachdb/cockroach/pkg/internal/team"
	"github.com/cockroachdb/errors"
	"github.com/zabawaba99/go-gitignore"
)

// Rule is a single rule within a CODEOWNERS file.
type Rule struct {
	Pattern string
	Owners  []team.Alias
}

// CodeOwners is a struct encapsulating a CODEOWNERS file.
type CodeOwners struct {
	rules []Rule
	teams map[team.Alias]team.Team
}

// GetTeamForAlias returns the team matching the given Alias.
func (co *CodeOwners) GetTeamForAlias(alias team.Alias) team.T
    
func (co *CodeOwners) Match(filePath string) []team.Team {
	if filepath.IsAbs(filePath) {
		// NB: don't try to look up the repository root here.
		// The callers should do that.
		return nil
	}
	filePath = string(filepath.Separator) + filepath.Clean(filePath)
	// filePath is now "absolute relative to the repo root", i.e.
	// `/pkg/acceptance`, and the cleaning helps avoid inputs like
	// `./pkg/acceptance` not working (when `pkg/acceptance` would).
	//
	// Keep matching until we hit the root directory.
	lastFilePath := ""
	for filePath != lastFilePath {
		// Rules are matched backwards.
		for i := len(co.rules) - 1; i >= 0; i-- {
			rule := co.rules[i]
			// For subdirectories, CODEOWNERS will add ** automatically for matches.
			// As such, if the pattern ends with a directory (i.e. '/'), add the ** operator implicitly.
			if gitignore.Match(rule.Pattern, filePath) {
				teams := make([]team.Team, len(rule.Owners))
				for i, owner := range rule.Owners {
					teams[i] = co.teams[owner]
				}
				return teams
			}
		}
		lastFilePath = filePath
		filePath = filepath.Dir(filePath)
	}
	return nil
}