Created
November 1, 2014 08:20
-
-
Save jcrubino/960bb1aee9c3bd0a44c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// minimal example of a golang gorrilla websocket client | |
package main | |
import "github.com/gorilla/websocket" | |
import "net/http" | |
import "log" | |
import "os" | |
func main() { | |
conn, _, err := websocket.DefaultDialer.Dial("ws://echo.websocket.org", http.Header{}) | |
if err != nil { | |
log.Println(err) | |
os.Exit(1) | |
} | |
msg := []byte("Hello, this is an echo test") | |
conn.WriteMessage(1, msg) | |
_, m, err := conn.ReadMessage() | |
if err == nil { | |
log.Println(string(m)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment