https://github.com/wangxianzhuo/web-console
It can print data on web by websocket
https://github.com/wangxianzhuo/web-console
go websocket
Last synced: 5 months ago
JSON representation
It can print data on web by websocket
- Host: GitHub
- URL: https://github.com/wangxianzhuo/web-console
- Owner: wangxianzhuo
- License: apache-2.0
- Created: 2018-03-10T14:23:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-10T14:25:26.000Z (over 8 years ago)
- Last Synced: 2024-10-30T20:53:41.381Z (over 1 year ago)
- Topics: go, websocket
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Web Console
>It can print data on web by websocket. But only have one server entity.
## Install
go get -u github.com/wangxianzhuo/web-console
## Usage
```golang
package main
import (
"bytes"
"time"
"github.com/wangxianzhuo/web-console/server"
)
func main() {
var buffer bytes.Buffer
server, _ := server.New(&buffer, nil)
go func() {
for {
time.Sleep(1 * time.Second)
// It can print newest time on web.
buffer.Write([]byte(time.Now().String()))
}
}()
server.Run("")
}
```
```shell
go run main.go
```
> Visiting `http://localhost:8080/` can see the newest time.