Skip to content

Commit

Permalink
Update to latest webrpc in go:generate
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek committed Oct 31, 2024
1 parent a5a85e3 commit 8a1631d
Show file tree
Hide file tree
Showing 12 changed files with 881 additions and 30 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# - name: Install webrpc-gen
# run: |
# curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.11.0/webrpc-gen.linux-amd64
# chmod +x ./webrpc-gen
# echo $PWD >> $GITHUB_PATH

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
- name: Install webrpc-gen (development)
run: git clone --single-branch https://github.com/webrpc/webrpc.git --branch master && cd webrpc && make install
go-version-file: "go.mod"

- name: Regenerate examples
run: cd _examples && make generate
Expand Down
9 changes: 3 additions & 6 deletions _examples/golang-basics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ A simple example of a Go web service built using webrpc.

The process of developing something like this is..

1. Start with your webrpc schema file, in this case, [./example.ridl](./example.ridl) in RIDL format.. or,
you can also write your schema in JSON format like so, [./example.webrpc.json](./example.webrpc.json). RIDL is simpler :)
2. Design your schema file and think about the methods calls clients will need to make
to your service
1. Start with your webrpc schema file, in this case, [./example.ridl](./example.ridl) in RIDL format.
2. Design your schema file and think about the methods calls clients will need to make to your service
3. Write the "services" section of the schema file
4. From the inputs and outputs for the function definitions, start writing the "structs"
section of the data types needed in your program.
4. From the inputs and outputs for the function definitions, start writing the "structs" section of the data types needed in your program.
5. Run the code generator to build the server and client:
* `webrpc-gen -schema=example.ridl -target=golang -pkg=main -server -client -out=./example.gen.go`
* or... * `webrpc-gen -schema=example.webrpc.json -target=golang -pkg=main -server -client -out=./example.gen.go`
Expand Down
4 changes: 2 additions & 2 deletions _examples/golang-basics/example.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions _examples/golang-basics/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -legacyErrors -fixEmptyArrays -out=./example.gen.go

import (
_ "github.com/webrpc/webrpc"
)
54 changes: 52 additions & 2 deletions _examples/golang-basics/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,62 @@ go 1.19

require (
github.com/go-chi/chi/v5 v5.0.10
github.com/google/uuid v1.3.0
github.com/stretchr/testify v1.8.1
github.com/google/uuid v1.6.0
github.com/stretchr/testify v1.9.0
github.com/webrpc/webrpc v0.21.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.12.0 // indirect
github.com/golang-cz/textcase v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/diff v0.0.1 // indirect
github.com/posener/gitfs v1.2.2 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/webrpc/gen-dart v0.1.1 // indirect
github.com/webrpc/gen-golang v0.16.0 // indirect
github.com/webrpc/gen-javascript v0.13.0 // indirect
github.com/webrpc/gen-kotlin v0.1.0 // indirect
github.com/webrpc/gen-openapi v0.15.0 // indirect
github.com/webrpc/gen-typescript v0.15.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/tools v0.21.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 8a1631d

Please sign in to comment.