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: grant.go
    path of file: ./repos/cockroach/pkg/sql/sem/tree
    
    the code of the file until where you have to start completion: // Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in licenses/BSD-vitess.txt.

// Portions of this file are additionally subject to the following
// license and copyright.
//
// Copyright 2015 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.

// This code was derived from https://github.com/youtube/vitess.

package tree

import "github.com/cockroachdb/cockroach/pkg/sql/privilege"

// Grant represents a GRANT statement.
type Grant struct {
	Privileges      privilege.List
	Targets         GrantTargetList
	Grantees        RoleSpecList
	WithGrantOption bool
}

// GrantTargetList represents a list of targets.
// Only one field may be non-nil.
type GrantTargetList struct {
	Databases  NameList
	Schemas    ObjectNamePrefixList
	Tables     TableAttrs
	Types      []*UnresolvedObjectName
	Functions  RoutineObjs
	Procedures RoutineObjs

    
func (tl *GrantTargetList) Format(ctx *FmtCtx) {
	if tl.Databases != nil {
		ctx.WriteString("DATABASE ")
		ctx.FormatNode(&tl.Databases)
	} else if tl.AllSequencesInSchema {
		ctx.WriteString("ALL SEQUENCES IN SCHEMA ")
		ctx.FormatNode(&tl.Schemas)
	} else if tl.AllTablesInSchema {
		ctx.WriteString("ALL TABLES IN SCHEMA ")
		ctx.FormatNode(&tl.Schemas)
	} else if tl.AllFunctionsInSchema {
		ctx.WriteString("ALL FUNCTIONS IN SCHEMA ")
		ctx.FormatNode(&tl.Schemas)
	} else if tl.AllProceduresInSchema {
		ctx.WriteString("ALL PROCEDURES IN SCHEMA ")
		ctx.FormatNode(&tl.Schemas)
	} else if tl.Schemas != nil {
		ctx.WriteString("SCHEMA ")
		ctx.FormatNode(&tl.Schemas)
	} else if tl.Types != nil {
		ctx.WriteString("TYPE ")
		for i, typ := range tl.Types {
			if i != 0 {
				ctx.WriteString(", ")
			}
			ctx.FormatNode(typ)
		}
	} else if tl.ExternalConnections != nil {
		ctx.WriteString("EXTERNAL CONNECTION ")
		ctx.FormatNode(&tl.ExternalConnections)
	} else if tl.Functions != nil {
		ctx.WriteString("FUNCTION ")
		ctx.FormatNode(tl.Functions)
	} else if tl.Procedures != nil {
		ctx.WriteString("PROCEDURE ")
		ctx.FormatNode(tl.Procedures)
	} else {
		if tl.Tables.SequenceOnly {
			ctx.WriteString("SEQUENCE ")
		} else {
			ctx.WriteString("TABLE ")
		}
		ctx.FormatNode(&tl.Tables.TablePatterns)
	}
}