Movatterモバイル変換


[0]ホーム

URL:


tool

package
v0.37.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2025 License:BSD-3-ClauseImports:11Imported by:0

Details

Repository

cs.opensource.google/go/x/tools

Links

Documentation

Overview

Package tool is a harness for writing Go tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcCommandLineErrorf

func CommandLineErrorf(messagestring, args ...any)error

CommandLineErrorf is like fmt.Errorf except that it returns a value thattriggers printing of the command line help.In general you should use this when generating command line validation errors.

funcMain

func Main(ctxcontext.Context, appApplication, args []string)

Main should be invoked directly by main function.It will only return if there was no error. If an errorwas encountered it is printed to standard error and theapplication exits with an exit code of 2.

funcRun

func Run(ctxcontext.Context, s *flag.FlagSet, appApplication, args []string) (resultErrerror)

Run is the inner loop for Main; invoked by Main, recursively byRun, and by various tests. It runs the application and returns anerror.

Types

typeApplication

type Application interface {// Name returns the application's name. It is used in help and error messages.Name()string// Most of the help usage is automatically generated, this string should only// describe the contents of non flag arguments.Usage()string// ShortHelp returns the one line overview of the command.ShortHelp()string// DetailedHelp should print a detailed help message. It will only ever be shown// when the ShortHelp is also printed, so there is no need to duplicate// anything from there.// It is passed the flag set so it can print the default values of the flags.// It should use the flag sets configured Output to write the help to.DetailedHelp(*flag.FlagSet)// Run is invoked after all flag processing, and inside the profiling and// error handling harness.Run(ctxcontext.Context, args ...string)error}

Application is the interface that must be satisfied by an object passed to Main.

typeProfile

type Profile struct {CPUstring `flag:"profile.cpu" help:"write CPU profile to this file"`Memorystring `flag:"profile.mem" help:"write memory profile to this file"`Allocstring `flag:"profile.alloc" help:"write alloc profile to this file"`Tracestring `flag:"profile.trace" help:"write trace log to this file"`Blockstring `flag:"profile.block" help:"write block profile to this file"`}

Profile can be embedded in your application struct to automaticallyadd command line arguments and handling for the common profiling methods.

typeSubCommandadded inv0.1.10

type SubCommand interface {Parent()string}

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp