Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed Mar 27, 2024
1 parent 83db3c1 commit c8d070c
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 15 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/protoc-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: protoc-gen-plugin Release

on:
release:
types: [published]

jobs:
release:
permissions:
contents: write
name: Release protoc-gen-plugin
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [386, amd64, arm64]
exclude:
- goos: darwin
goarch: 386

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2

- name: Download dependencies
run: |
go mod download
- name: Prepare build directory
run: |
mkdir -p build/
cp README.md build/
cp LICENSE build/
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -trimpath -o $GITHUB_WORKSPACE/build
- name: Create package
id: package
run: |
PACKAGE_NAME=protoc-gen-plugin.${GITHUB_REF#refs/tags/}.${{ matrix.goos }}.${{ matrix.goarch }}.tar.gz
tar -czvf $PACKAGE_NAME -C build .
echo "name=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
- name: Upload asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ steps.package.outputs.name }}
asset_name: ${{ steps.package.outputs.name }}
asset_content_type: application/gzip

18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Before using `protoc-gen-go-triple`, make sure you have the following prerequisi
To install `protoc-gen-go-triple`, you can use the `go get` command:

```shell
go get dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple
go get github.com/dubbogo/protoc-gen-go-triple
```

Alternatively, you can clone the GitHub repository and build the binary manually:

```shell
git clone https://github.com/apache/dubbo-go.git
cd cmd/protoc-gen-go-triple
git clone https://github.com/dubbogo/protoc-gen-go-triple.git
cd protoc-gen-go-triple
go build
```

Expand All @@ -47,6 +47,8 @@ Both the `--go_out` flag and `--go-triple_out` flag should be set to `.`. Please

## Example

More dubbo examples using this protoc plugin can be found here [apache/dubbo-go-samples](https://github.com/apache/dubbo-go-samples/)

Let's say you have a Protocol Buffer file named `greet.proto`, and you want to generate Triple Go code from it.

```proto
Expand All @@ -55,7 +57,7 @@ syntax = "proto3";
package greet;
option go_package = "dubbo.apache.org/dubbo-go/v3/protocol/triple/internal/proto/dubbo3_gen;greet";
option go_package = "github.com/apache/dubbo-go-samples/helloworld/proto;greet";
message GreetRequest {
string name = 1;
Expand Down Expand Up @@ -83,10 +85,10 @@ Both parts are indispensable. The directory for the file is determined before `;
Resulting in the following directory structure:

```
dubbo-go/protocol/triple/internal/proto/
|-triple_gen
greet.pb.go
greet.triple.go
github.com/apache/dubbo-go-samples/helloworld
|-proto
greet.pb.go
greet.triple.go
```

The package for `greet.pb.go` and `greet.triple.go` are `greet`
Expand Down
2 changes: 1 addition & 1 deletion gen/generator/genTriple.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

import (
"dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple/util"
"github.com/dubbogo/protoc-gen-go-triple/util"
)

func (g *Generator) parseTripleToString(t TripleGo) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion gen/generator/tripleTpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

import (
"dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple/util"
"github.com/dubbogo/protoc-gen-go-triple/util"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple
module github.com/dubbogo/protoc-gen-go-triple

go 1.20

Expand Down
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ import (

import (
"google.golang.org/protobuf/compiler/protogen"

"google.golang.org/protobuf/types/pluginpb"
)

import (
"dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple/gen/generator"
"dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple/internal/old_triple"
"dubbo.apache.org/dubbo-go/v3/cmd/protoc-gen-go-triple/internal/version"
"github.com/dubbogo/protoc-gen-go-triple/gen/generator"
"github.com/dubbogo/protoc-gen-go-triple/internal/old_triple"
"github.com/dubbogo/protoc-gen-go-triple/internal/version"
)

const (
Expand Down

0 comments on commit c8d070c

Please sign in to comment.