github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/gorilla/websocket/examples/command/README.md (about)

     1  # Command example
     2  
     3  This example connects a websocket connection to stdin and stdout of a command.
     4  Received messages are written to stdin followed by a `\n`. Each line read from
     5  from standard out is sent as a message to the client.
     6  
     7      $ go get github.com/gorilla/websocket
     8      $ cd `go list -f '{{.Dir}}' github.com/gorilla/websocket/examples/command`
     9      $ go run main.go <command and arguments to run>
    10      # Open http://localhost:8080/ .
    11  
    12  Try the following commands.
    13  
    14      # Echo sent messages to the output area.
    15      $ go run main.go cat
    16  
    17      # Run a shell.Try sending "ls" and "cat main.go".
    18      $ go run main.go sh
    19