diff --git a/README.md b/README.md index 5f2b498..c7cec48 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,8 @@ Go also provides: - WebSocket: `NewWsServer`, `DialWs`, `NewWsServerTLS`, `DialWss` - 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 diff --git a/examples/go-module-consumer/README.md b/examples/go-module-consumer/README.md new file mode 100644 index 0000000..811f12b --- /dev/null +++ b/examples/go-module-consumer/README.md @@ -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 +``` + +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 . +``` diff --git a/examples/go-module-consumer/go.mod b/examples/go-module-consumer/go.mod new file mode 100644 index 0000000..eaf51b3 --- /dev/null +++ b/examples/go-module-consumer/go.mod @@ -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 +) diff --git a/examples/go-module-consumer/go.sum b/examples/go-module-consumer/go.sum new file mode 100644 index 0000000..0c9fda8 --- /dev/null +++ b/examples/go-module-consumer/go.sum @@ -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= diff --git a/examples/go-module-consumer/main.go b/examples/go-module-consumer/main.go new file mode 100644 index 0000000..8a41795 --- /dev/null +++ b/examples/go-module-consumer/main.go @@ -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") +}