Skip to content

Commit

Permalink
fix bug: mage protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
skiffer-git committed Jun 19, 2024
1 parent 98e8c9e commit da209e9
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions mageutil/gen_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,35 @@ func Protocol() error {
}
return nil
}

func compileProtoFiles(basePath, dirName, moduleName string) error {
protoFile := filepath.Join(basePath, dirName, dirName+".proto")
outputDir := filepath.Join(basePath, dirName)
module := moduleName + "/pkg/protocol/" + dirName

// Include the base path and potentially other necessary paths
includePaths := []string{
basePath, // Current proto files directory
filepath.Join(basePath, "common"), // Common protos directory, if exists
}

// Build the args for the protoc command
args := []string{
"--go_out=plugins=grpc:" + outputDir,
"--go_opt=module=" + module,
protoFile,
"--proto_path=" + strings.Join(includePaths, ":"), // Setting multiple proto paths
"--go_out=plugins=grpc:" + outputDir, // Output directory
"--go_opt=module=" + module, // Module name
protoFile, // Proto file to compile
}

// Print which file is being compiled for clarity
fmt.Printf("Compiling %s...\n", protoFile)

// Execute the protoc command
if err := sh.Run("protoc", args...); err != nil {
return fmt.Errorf("failed to compile %s: %s", protoFile, err)
}

// Attempt to fix 'omitempty' in all generated .pb.go files within the directory
return fixOmitemptyInDirectory(outputDir)
}

Expand Down

0 comments on commit da209e9

Please sign in to comment.