Skip to content

Commit 748a906

Browse files
committed
_example: add zerovalue example and test
1 parent 1736fbd commit 748a906

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

_example/zerovalue/go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module example/default
2+
3+
go 1.23.0
4+
5+
toolchain go1.24.5
6+
7+
require github.com/arl/statsviz v0.7.1
8+
9+
require github.com/gorilla/websocket v1.5.3 // indirect
10+
11+
replace github.com/arl/statsviz => ../../

_example/zerovalue/go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
2+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
3+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
4+
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
5+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
6+
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
7+
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
8+
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=

_example/zerovalue/main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net/http"
7+
8+
"github.com/arl/statsviz"
9+
example "github.com/arl/statsviz/_example"
10+
)
11+
12+
func main() {
13+
// Force the GC to work to make the plots "move".
14+
go example.Work()
15+
16+
// Register with the Server zero value.
17+
var ss statsviz.Server
18+
ss.Register(http.DefaultServeMux)
19+
20+
fmt.Println("Point your browser to http://localhost:8079/debug/statsviz/")
21+
log.Fatal(http.ListenAndServe(":8079", nil))
22+
}

zerovalue.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cp $STATSVIZ_ROOT/_example/default/main.go .
2+
cp $STATSVIZ_ROOT/_example/default/go.mod .
3+
4+
go mod edit -replace=github.com/arl/statsviz=$STATSVIZ_ROOT
5+
go mod edit -replace=github.com/arl/statsviz/_example=$STATSVIZ_ROOT/_example
6+
go mod tidy
7+
8+
go build main.go
9+
! exec ./main &
10+
checkui http://localhost:8079/debug/statsviz/

0 commit comments

Comments
 (0)