### Install Phx Go Client Source: https://github.com/nshafer/phx/blob/main/README.md This command installs the Phx Go client library using `go get`. It requires Go 1.18 or later to function correctly. ```Go go get github.com/nshafer/phx ``` -------------------------------- ### Connect and Interact with Phoenix Channel in Go Source: https://github.com/nshafer/phx/blob/main/README.md This Go example demonstrates how to establish a connection to a Phoenix socket, join a specific channel, send an event (ping) to the channel, and set up a listener for incoming messages (shout) from the server. This snippet illustrates basic client-server interaction without error handling. ```Go // Connect to socket endPoint, _ := url.Parse("ws://localhost:4000/socket?foo=bar") socket := phx.NewSocket(endPoint) _ = socket.Connect() // Join a channel channel := socket.Channel("test:lobby", nil) join, _ := channel.Join() join.Receive("ok", func(response any) { log.Println("Joined channel:", channel.Topic(), response) }) // Send an event ping, _ := channel.Push("ping", "pong") ping.Receive("ok", func(response any) { log.Println("Ping:", response) }) // Listen for pushes or broadcasts from the server channel.On("shout", func(payload any) { log.Println("received shout:", payload) }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.