Documentation
¶
Index ¶
- Constants
- func FindProtoFiles(dir string, excludePaths []string) ([]string, error)
- func FormatProto(source string) string
- func OutputResults(w io.Writer, results []LintResult, format string) error
- func RunBreaking(w io.Writer, dir string, opts BreakingOptions) error
- func RunBuild(w io.Writer, dir string, opts BuildOptions) error
- func RunDepUpdate(w io.Writer, dir string) error
- func RunFormat(w io.Writer, dir string, opts FormatOptions) error
- func RunGenerate(w io.Writer, dir string, opts GenerateOptions) error
- func RunInit(w io.Writer, dir string, moduleName string) error
- func RunLint(w io.Writer, dir string, opts LintOptions) error
- func RunLsFiles(w io.Writer, dir string) error
- type BreakingConfig
- type BreakingOptions
- type BuildOptions
- type BuildResult
- type Config
- type FormatOptions
- type FormatResult
- type GenerateConfig
- type GenerateOptions
- type GoPackagePrefix
- type Lexer
- type LintConfig
- type LintOptions
- type LintResult
- type LintRule
- type ManagedConfig
- type Options
- type Parser
- type PluginConfig
- type ProtoComment
- type ProtoEnum
- type ProtoEnumValue
- type ProtoField
- type ProtoFile
- type ProtoImage
- type ProtoImageFile
- type ProtoImport
- type ProtoMessage
- type ProtoMethod
- type ProtoOption
- type ProtoService
- type Token
- type TokenType
Constants ¶
const ( CategoryMinimal = "MINIMAL" CategoryBasic = "BASIC" CategoryStandard = "STANDARD" CategoryComments = "COMMENTS" )
Lint rule categories
Variables ¶
This section is empty.
Functions ¶
func FindProtoFiles ¶
FindProtoFiles finds all .proto files in a directory
func OutputResults ¶
func OutputResults(w io.Writer, results []LintResult, format string) error
OutputResults outputs results in the specified format
func RunBreaking ¶
func RunBreaking(w io.Writer, dir string, opts BreakingOptions) error
RunBreaking checks for breaking changes
func RunBuild ¶
func RunBuild(w io.Writer, dir string, opts BuildOptions) error
RunBuild builds proto files
func RunDepUpdate ¶
RunDepUpdate updates dependencies (placeholder)
func RunFormat ¶
func RunFormat(w io.Writer, dir string, opts FormatOptions) error
RunFormat formats proto files
func RunGenerate ¶
func RunGenerate(w io.Writer, dir string, opts GenerateOptions) error
RunGenerate generates code from proto files
Types ¶
type BreakingConfig ¶
type BreakingConfig struct {
Use []string `yaml:"use,omitempty"`
Except []string `yaml:"except,omitempty"`
Ignore []string `yaml:"ignore,omitempty"`
}
BreakingConfig represents breaking change configuration
type BreakingOptions ¶
type BreakingOptions struct {
Options
Against string // Source to compare against
ExcludeImports bool // Don't check imported files
}
BreakingOptions configures buf breaking
type BuildOptions ¶
BuildOptions configures buf build
type BuildResult ¶
type BuildResult struct {
Success bool `json:"success"`
Files []string `json:"files"`
Errors []string `json:"errors,omitempty"`
}
BuildResult represents build output
type Config ¶
type Config struct {
Version string `yaml:"version"`
Name string `yaml:"name,omitempty"`
Deps []string `yaml:"deps,omitempty"`
Lint LintConfig `yaml:"lint,omitempty"`
Breaking BreakingConfig `yaml:"breaking,omitempty"`
}
Config represents buf.yaml configuration
func LoadConfig ¶
LoadConfig loads buf.yaml from a directory
type FormatOptions ¶
type FormatOptions struct {
Write bool // Rewrite files in place
Diff bool // Display diff
ExitCode bool // Exit with non-zero if files unformatted
}
FormatOptions configures buf format
type FormatResult ¶
type FormatResult struct {
File string `json:"file"`
Formatted bool `json:"formatted"`
Diff string `json:"diff,omitempty"`
BytesDiff int `json:"bytes_diff,omitempty"`
}
FormatResult represents format output
type GenerateConfig ¶
type GenerateConfig struct {
Version string `yaml:"version"`
Plugins []PluginConfig `yaml:"plugins"`
Clean bool `yaml:"clean,omitempty"`
Managed ManagedConfig `yaml:"managed,omitempty"`
}
GenerateConfig represents buf.gen.yaml configuration
func LoadGenerateConfig ¶
func LoadGenerateConfig(dir string) (*GenerateConfig, error)
LoadGenerateConfig loads buf.gen.yaml from a directory
type GenerateOptions ¶
type GenerateOptions struct {
Template string // Alternate buf.gen.yaml location
Output string // Base output directory
IncludeImports bool // Include imported files
}
GenerateOptions configures buf generate
type GoPackagePrefix ¶
type GoPackagePrefix struct {
Default string `yaml:"default"`
}
GoPackagePrefix represents go_package_prefix configuration
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer tokenizes proto source
type LintConfig ¶
type LintConfig struct {
Use []string `yaml:"use,omitempty"`
Except []string `yaml:"except,omitempty"`
Ignore []string `yaml:"ignore,omitempty"`
IgnoreOnly map[string][]string `yaml:"ignore_only,omitempty"`
}
LintConfig represents lint configuration
type LintResult ¶
type LintResult struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Rule string `json:"rule"`
Message string `json:"message"`
}
LintResult represents a lint issue
type LintRule ¶
type LintRule struct {
ID string
Category string
Check func(*ProtoFile, string) []LintResult
}
LintRule represents a lint rule
type ManagedConfig ¶
type ManagedConfig struct {
Enabled bool `yaml:"enabled"`
GoPackagePrefix GoPackagePrefix `yaml:"go_package_prefix,omitempty"`
}
ManagedConfig represents managed mode configuration
type Options ¶
type Options struct {
ErrorFormat string // Output format: text, json, github-actions
ExcludePath []string // Paths to exclude
Path []string // Specific paths to process
Config string // Custom config file path
}
Options configures common buf options
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses proto tokens into a ProtoFile
type PluginConfig ¶
type PluginConfig struct {
Remote string `yaml:"remote,omitempty"`
Local string `yaml:"local,omitempty"`
Out string `yaml:"out"`
Opt []string `yaml:"opt,omitempty"`
}
PluginConfig represents a plugin configuration
type ProtoComment ¶
ProtoComment represents a comment in the proto file
type ProtoEnum ¶
type ProtoEnum struct {
Name string
Values []ProtoEnumValue
Options []ProtoOption
Line int
}
ProtoEnum represents a proto enum
type ProtoEnumValue ¶
type ProtoEnumValue struct {
Name string
Number int
Options []ProtoOption
Line int
}
ProtoEnumValue represents a proto enum value
type ProtoField ¶
type ProtoField struct {
Name string
Type string
Number int
Label string // optional, required, repeated
Options []ProtoOption
Line int
Comments []string
}
ProtoField represents a proto field
type ProtoFile ¶
type ProtoFile struct {
Syntax string
Package string
Options []ProtoOption
Imports []ProtoImport
Messages []ProtoMessage
Enums []ProtoEnum
Services []ProtoService
Comments []ProtoComment
}
ProtoFile represents a parsed proto file
func ParseProtoFile ¶
ParseProtoFile parses a proto file from source
type ProtoImage ¶
type ProtoImage struct {
Files []ProtoImageFile `json:"files"`
}
ProtoImage represents a compiled protobuf image
type ProtoImageFile ¶
type ProtoImageFile struct {
Name string `json:"name"`
Package string `json:"package"`
Syntax string `json:"syntax"`
Messages []string `json:"messages,omitempty"`
Enums []string `json:"enums,omitempty"`
Services []string `json:"services,omitempty"`
Imports []string `json:"imports,omitempty"`
Options map[string]string `json:"options,omitempty"`
}
ProtoImageFile represents a file in the image
type ProtoImport ¶
ProtoImport represents a proto import
type ProtoMessage ¶
type ProtoMessage struct {
Name string
Fields []ProtoField
Nested []ProtoMessage
Enums []ProtoEnum
Options []ProtoOption
Reserved []string
Line int
Comments []string
}
ProtoMessage represents a proto message
type ProtoMethod ¶
type ProtoMethod struct {
Name string
InputType string
OutputType string
ClientStreaming bool
ServerStreaming bool
Options []ProtoOption
Line int
}
ProtoMethod represents a proto RPC method
type ProtoOption ¶
ProtoOption represents a proto option
type ProtoService ¶
type ProtoService struct {
Name string
Methods []ProtoMethod
Options []ProtoOption
Line int
}
ProtoService represents a proto service