Skip to content

Commit d45f5a4

Browse files
authored
Update examples to latest webrpc, use tools submodule (#76)
* Update to latest webrpc in go:generate * go mod tidy * Move to tools submodule * Use Go 1.19
1 parent a5a85e3 commit d45f5a4

File tree

18 files changed

+1043
-47
lines changed

18 files changed

+1043
-47
lines changed

.github/workflows/ci.yml

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16-
# - name: Install webrpc-gen
17-
# run: |
18-
# curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.11.0/webrpc-gen.linux-amd64
19-
# chmod +x ./webrpc-gen
20-
# echo $PWD >> $GITHUB_PATH
2116

2217
- name: Set up Go
2318
uses: actions/setup-go@v3
2419
with:
25-
go-version: "1.20"
26-
- name: Install webrpc-gen (development)
27-
run: git clone --single-branch https://github.com/webrpc/webrpc.git --branch master && cd webrpc && make install
20+
go-version: "1.19"
2821

2922
- name: Regenerate examples
3023
run: cd _examples && make generate

_examples/golang-basics/README.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ A simple example of a Go web service built using webrpc.
88

99
The process of developing something like this is..
1010

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

_examples/golang-basics/example.gen.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_examples/golang-basics/go.mod

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ go 1.19
44

55
require (
66
github.com/go-chi/chi/v5 v5.0.10
7-
github.com/google/uuid v1.3.0
8-
github.com/stretchr/testify v1.8.1
7+
github.com/google/uuid v1.6.0
8+
github.com/stretchr/testify v1.9.0
99
)
1010

1111
require (
1212
github.com/davecgh/go-spew v1.1.1 // indirect
13+
github.com/kr/pretty v0.3.1 // indirect
1314
github.com/pmezard/go-difflib v1.0.0 // indirect
15+
github.com/rogpeppe/go-internal v1.11.0 // indirect
16+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
1417
gopkg.in/yaml.v3 v3.0.1 // indirect
1518
)

_examples/golang-basics/go.sum

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
55
github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
6-
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
7-
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
6+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
7+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
8+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
9+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
10+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
11+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
12+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
13+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
14+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
15+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
816
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
917
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
10-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
11-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
12-
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
13-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
14-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
15-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
16-
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
17-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
18+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
19+
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
20+
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
21+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
22+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
1823
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
19-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
24+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
25+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
2026
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2127
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

_examples/golang-basics/go.work

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use (
2+
.
3+
./tools
4+
)

_examples/golang-basics/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//go:generate webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -legacyErrors -fixEmptyArrays -out=./example.gen.go
21
package main
32

3+
//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
4+
45
import (
56
"context"
67
"fmt"

_examples/golang-basics/tools/go.mod

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module tools
2+
3+
go 1.19
4+
5+
require github.com/webrpc/webrpc v0.21.0
6+
7+
require (
8+
dario.cat/mergo v1.0.0 // indirect
9+
github.com/Masterminds/goutils v1.1.1 // indirect
10+
github.com/Masterminds/semver/v3 v3.2.1 // indirect
11+
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
12+
github.com/Microsoft/go-winio v0.6.1 // indirect
13+
github.com/ProtonMail/go-crypto v1.0.0 // indirect
14+
github.com/cloudflare/circl v1.3.7 // indirect
15+
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
16+
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/emirpasic/gods v1.18.1 // indirect
18+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
19+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
20+
github.com/go-git/go-git/v5 v5.12.0 // indirect
21+
github.com/golang-cz/textcase v1.2.1 // indirect
22+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
23+
github.com/google/go-github v17.0.0+incompatible // indirect
24+
github.com/google/go-querystring v1.1.0 // indirect
25+
github.com/google/uuid v1.6.0 // indirect
26+
github.com/huandu/xstrings v1.4.0 // indirect
27+
github.com/imdario/mergo v0.3.16 // indirect
28+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
29+
github.com/kevinburke/ssh_config v1.2.0 // indirect
30+
github.com/kr/fs v0.1.0 // indirect
31+
github.com/mitchellh/copystructure v1.2.0 // indirect
32+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
33+
github.com/pjbgf/sha1cd v0.3.0 // indirect
34+
github.com/pkg/errors v0.9.1 // indirect
35+
github.com/posener/diff v0.0.1 // indirect
36+
github.com/posener/gitfs v1.2.2 // indirect
37+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
38+
github.com/shopspring/decimal v1.4.0 // indirect
39+
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect
40+
github.com/skeema/knownhosts v1.2.2 // indirect
41+
github.com/spf13/cast v1.6.0 // indirect
42+
github.com/webrpc/gen-dart v0.1.1 // indirect
43+
github.com/webrpc/gen-golang v0.16.0 // indirect
44+
github.com/webrpc/gen-javascript v0.13.0 // indirect
45+
github.com/webrpc/gen-kotlin v0.1.0 // indirect
46+
github.com/webrpc/gen-openapi v0.15.0 // indirect
47+
github.com/webrpc/gen-typescript v0.15.0 // indirect
48+
github.com/xanzy/ssh-agent v0.3.3 // indirect
49+
golang.org/x/crypto v0.23.0 // indirect
50+
golang.org/x/mod v0.17.0 // indirect
51+
golang.org/x/net v0.25.0 // indirect
52+
golang.org/x/sync v0.7.0 // indirect
53+
golang.org/x/sys v0.20.0 // indirect
54+
golang.org/x/tools v0.21.0 // indirect
55+
gopkg.in/warnings.v0 v0.1.2 // indirect
56+
)

0 commit comments

Comments
 (0)