patch

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package patch is command set for patching service code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptMonoRepoCommand

func AdaptMonoRepoCommand() *cobra.Command

AdaptMonoRepoCommand Adapt to mono-repo command

func CheckAndModifyDuplicateErrorCodeNO added in v1.13.0

func CheckAndModifyDuplicateErrorCodeNO(errorCodeNOs []*ErrorCodeNOAst) error

CheckAndModifyDuplicateErrorCodeNO check and modify duplicate error code NO

func CopyGOModCommand

func CopyGOModCommand() *cobra.Command

CopyGOModCommand copy go mod files

func CopyProtoCommand

func CopyProtoCommand() *cobra.Command

CopyProtoCommand copy proto file from the grpc service directory

func CopyThirdPartyProtoCommand

func CopyThirdPartyProtoCommand() *cobra.Command

CopyThirdPartyProtoCommand copy third-party proto files

func DeleteJSONOmitemptyCommand

func DeleteJSONOmitemptyCommand() *cobra.Command

DeleteJSONOmitemptyCommand delete json omitempty

func GenTypesPbCommand

func GenTypesPbCommand() *cobra.Command

GenTypesPbCommand generate types.proto code

func GenerateDBInitCommand

func GenerateDBInitCommand() *cobra.Command

GenerateDBInitCommand generate database initialization code

func ModifyDuplicateErrorCodeNumCommand added in v1.13.0

func ModifyDuplicateErrorCodeNumCommand() *cobra.Command

ModifyDuplicateErrorCodeNumCommand Command modify duplicate error code numbers

func ModifyDuplicateErrorCodeOffsetCommand added in v1.13.0

func ModifyDuplicateErrorCodeOffsetCommand() *cobra.Command

ModifyDuplicateErrorCodeOffsetCommand modify duplicate error code offset command

func ModifyProtoPackageCommand

func ModifyProtoPackageCommand() *cobra.Command

ModifyProtoPackageCommand modifies the package and go_package names of proto files.

Types

type Deconstruction added in v1.13.0

type Deconstruction struct {
	VarName    string
	VarValue   int
	VarSrcCode string
}

Deconstruction is the struct for error code offset deconstruction

type ErrorCodeNOAst added in v1.13.0

type ErrorCodeNOAst struct {
	FilePath string
	SrcCode  string

	VarName    string // example: userExampleNO
	VarValue   int    // example: 1
	VarSrcCode string // example: "userExampleNO = 1"
	// contains filtered or unexported fields
}

ErrorCodeNOAst is the struct for error code NO

func NewErrorCodeNOAst added in v1.13.0

func NewErrorCodeNOAst(filePath string) ([]*ErrorCodeNOAst, error)

NewErrorCodeNOAst create a ErrorCodeNOAst object

func (*ErrorCodeNOAst) SaveToFile added in v1.13.0

func (e *ErrorCodeNOAst) SaveToFile(maxErrorCodeNO int) error

SaveToFile save the modified source code to file

type ErrorCodeOffset added in v1.13.0

type ErrorCodeOffset struct {
	Name string

	OffsetInfos []*Deconstruction

	VarNameCodeSrcMap map[string]string // varName -> varErrCodeSrc
	Body              string
	// contains filtered or unexported fields
}

ErrorCodeOffset is the struct for error code offset

func (*ErrorCodeOffset) CheckDuplicateErrorCodeOffset added in v1.13.0

func (c *ErrorCodeOffset) CheckDuplicateErrorCodeOffset(srcCode string) (string, bool)

CheckDuplicateErrorCodeOffset check if the error code offset has duplicate value

func (*ErrorCodeOffset) CheckMergedItems added in v1.13.0

func (c *ErrorCodeOffset) CheckMergedItems(srcCode string, codeInfo *ErrorCodeOffset) (string, bool)

CheckMergedItems check if the merged items have duplicate error code offset

type ErrorCodeOffsetAst added in v1.13.0

type ErrorCodeOffsetAst struct {
	FilePath string
	SrcCode  string
	FileSize int

	ErrorCodeNameInfoMap map[string]*ErrorCodeOffset
}

ErrorCodeOffsetAst is the struct for error code offset

func NewErrorCodeOffsetAst added in v1.13.0

func NewErrorCodeOffsetAst(filePath string) (*ErrorCodeOffsetAst, error)

NewErrorCodeOffsetAst create a ErrorCodeOffsetAst object

type Result added in v1.13.0

type Result struct {
	VarName        string
	BaseCodeOffset int
}

type Visitor added in v1.13.0

type Visitor struct {
	PackageName  string
	CallFuncName string
	// contains filtered or unexported fields
}

Visitor is a visitor that walks the AST and extracts error code offsets.

func (*Visitor) Visit added in v1.13.0

func (v *Visitor) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL