feat: add go-module-consumer example and update README

This commit is contained in:
toki 2026-05-02 07:47:52 +09:00
parent d0754a353a
commit a4380dadda
5 changed files with 73 additions and 0 deletions

View file

@ -163,6 +163,8 @@ Go also provides:
- WebSocket: `NewWsServer`, `DialWs`, `NewWsServerTLS`, `DialWss` - WebSocket: `NewWsServer`, `DialWs`, `NewWsServerTLS`, `DialWss`
- Shared helpers: `Send`, `SendRequest`, `AddListenerTyped`, `AddRequestListenerTyped`, `Broadcast` - Shared helpers: `Send`, `SendRequest`, `AddListenerTyped`, `AddRequestListenerTyped`, `Broadcast`
If you want a copyable scaffold for using this module from another repository, see [examples/go-module-consumer/](examples/go-module-consumer/).
--- ---
## Running Tests ## Running Tests

View file

@ -0,0 +1,39 @@
# Go Module Consumer
Minimal scaffold for consuming Proto Socket from another Go project.
## Private Registry Setup
This module path is hosted on a private Forgejo instance.
```bash
go env -w GOPRIVATE=git.toki-labs.com
go env -w GONOSUMDB=git.toki-labs.com
```
If authentication is required, configure either `~/.netrc`:
```text
machine git.toki-labs.com
login toki
password <personal_access_token>
```
or a Git URL rewrite:
```bash
git config --global url."https://toki@git.toki-labs.com/".insteadOf "https://git.toki-labs.com/"
```
## Install Or Update
```bash
go get git.toki-labs.com/toki/common-proto-socket/go@latest
go mod tidy
```
## Run
```bash
go run .
```

View file

@ -0,0 +1,10 @@
module example.com/proto-socket-go-consumer
go 1.22
require git.toki-labs.com/toki/common-proto-socket/go v0.0.0-20260501220005-284b66a22300
require (
google.golang.org/protobuf v1.36.5 // indirect
nhooyr.io/websocket v1.8.17 // indirect
)

View file

@ -0,0 +1,10 @@
git.toki-labs.com/toki/common-proto-socket/go v0.0.0-20260501220005-284b66a22300 h1:wvESR2WEz1yPqWRGZB2ORUewbI2K71++zOKyfpHcAkc=
git.toki-labs.com/toki/common-proto-socket/go v0.0.0-20260501220005-284b66a22300/go.mod h1:rEQJuwkoWQgOHXU4ijUinhhNzq92f+xzAkHti3CD3pA=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y=
nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=

View file

@ -0,0 +1,12 @@
package main
import (
"fmt"
protoSocket "git.toki-labs.com/toki/common-proto-socket/go"
)
func main() {
_ = protoSocket.NewTcpServer
fmt.Println("proto-socket import OK")
}