forked from emicklei/hopwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
57 lines (37 loc) · 1.62 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2012 Ernest Micklei. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
/*
Hopwatch is a debugging tool for Go programs.
Hopwatch uses a HTML5 application to connect to your program (using a Websocket).
Using Hopwatch requires adding function calls at points of interest that allow you to watch program state and suspend the program.
On the Hopwatch page, you can view debug information (file:line,stack) and choose to resume the execution of your program.
You can provide more debug information using the Display function which takes an arbitrary number of variable,value pairs.
The Display function itself does not suspend the program ; it is like having logging information in the browser.
Usage:
import (
"github.com/emicklei/hopwatch"
)
func foo() {
bar := "john"
// suspends execution until hitting "Resume" in the browser
hopwatch.Display("foo", bar).Break()
}
Connect:
Open the Hopwatch debugger on http://localhost:23456/hopwatch.html after starting your program.
Your browser must support WebSockets. It has been tested with Chrome and Safari on a Mac.
Other examples:
// zero or more conditions ; conditionally suspends program (or goroutine)
hopwatch.Break(i > 10, j < 100)
// zero or more name,value pairs ; no program suspend
hopwatch.Display("i",i , "j",j")
The flags are:
-hopwatch if set to false then hopwatch is disabled.
Install:
go get -u github.com/emicklei/hopwatch
Resources:
https://github.com/emicklei/hopwatch
http://ernestmicklei.com (blog)
(c) 2012, Ernest Micklei. MIT License
*/
package hopwatch