File tree 3 files changed +52
-3
lines changed
3 files changed +52
-3
lines changed Original file line number Diff line number Diff line change 3
3
[ ![ Build status] ( https://circleci.com/gh/google/gops/tree/master.svg?style=shield&circle-token=2637dc1e57d5407ae250480a86a2e553a7d20482 )] ( https://circleci.com/gh/google/gops )
4
4
[ ![ GoDoc] ( https://godoc.org/github.com/google/gops?status.svg )] ( https://godoc.org/github.com/google/gops )
5
5
6
+
7
+ 测试案例效果:
8
+ ``` sh
9
+ ╭─iceinto@iceinto ~
10
+ ╰─$ gops
11
+ 49371 49352 main* go1.11.2 /private/var/folders/9x/c1cwb3n9005_v5lr25jx0dtm0000gp/T/go-build216332130/b001/exe/main
12
+ 49412 47968 gops go1.11.2 /Users/iceinto/Documents/go/bin/gops
13
+ 49352 48729 go go1.11.2 /usr/local/go/bin/go
14
+ ╭─iceinto@iceinto ~
15
+ ╰─$ gops 49371
16
+ parent PID: 49352
17
+ threads: 6
18
+ memory usage: 0.062%
19
+ cpu usage: 0.093%
20
+ username: iceinto
21
+ cmd+args: /var/folders/9x/c1cwb3n9005_v5lr25jx0dtm0000gp/T/go-build216332130/b001/exe/main
22
+ local/remote: 127.0.0.1:61338 < -> :0 (LISTEN)
23
+ local/remote: * :8080 < -> :0 (LISTEN)
24
+ ```
25
+
26
+
6
27
gops is a command to list and diagnose Go processes currently running on your system.
7
28
8
29
``` sh
Original file line number Diff line number Diff line change @@ -2,14 +2,24 @@ package main
2
2
3
3
import (
4
4
"log"
5
- "time"
6
5
6
+ "github.com/astaxie/beego"
7
7
"github.com/google/gops/agent"
8
8
)
9
9
10
+ type MainController struct {
11
+ beego.Controller
12
+ }
13
+
14
+ func (this * MainController ) Get () {
15
+ this .Ctx .WriteString ("hello world" )
16
+ }
17
+
10
18
func main () {
11
- if err := agent .Listen (nil ); err != nil {
19
+ if err := agent .Listen (agent. Options {} ); err != nil {
12
20
log .Fatal (err )
13
21
}
14
- time .Sleep (time .Hour )
22
+ beego .SetLevel (beego .LevelDebug )
23
+ beego .Router ("/" , & MainController {})
24
+ beego .Run ()
15
25
}
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "go.uber.org/atomic"
7
+ )
8
+
9
+ func main () {
10
+ // Uint32 is a thin wrapper around the primitive uint32 type.
11
+ var atom atomic.Uint32
12
+
13
+ // The wrapper ensures that all operations are atomic.
14
+ atom .Store (42 )
15
+ fmt .Println (atom .Inc ())
16
+ fmt .Println (atom .CAS (43 , 0 ))
17
+ fmt .Println (atom .Load ())
18
+ }
You can’t perform that action at this time.
0 commit comments