hopwatch

package module
v0.0.0-...-ff98e67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2012 License: MIT Imports: 11 Imported by: 0

README

Hopwatch, a debugging tool for Go

Hopwatch is an experimental tool in HTML5 that can help debugging Go programs. It works by communicating to a WebSockets based client in Javascript. When your program calls the Break function, it sends debug information to the browser page and waits for user interaction. On the hopwatch page, the developer can view debug information and choose to resume the execution of the program.

###Documentation

http://go.pkgdoc.org/github.com/emicklei/hopwatch

© 2012, http://ernestmicklei.com. MIT License

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Break

func Break(conditions ...bool)

Break suspends the execution of the program and waits for an instruction from the debugger (e.g. Resume). Break is only effective if all (if any) conditions are true. The program will resume otherwise.

Types

type Watchpoint

type Watchpoint struct {
	// contains filtered or unexported fields
}

watchpoint is a helper to provide a fluent style api. This allows for statements like hopwatch.Display("var",value).Break()

func CallerOffset

func CallerOffset(offset int) *Watchpoint

CallerOffset (default=2) allows you to change the file indicator in hopwatch. Use this method when you wrap the .CallerOffset(..).Display(..).Break() in your own function.

func Display

func Display(nameValuePairs ...interface{}) *Watchpoint

Display sends variable name,value pairs to the debugger. The parameter nameValuePairs must be even sized.

func (Watchpoint) Break

func (self Watchpoint) Break(conditions ...bool)

Break halts the execution of the program and waits for an instruction from the debugger (e.g. Resume). Break is only effective if all (if any) conditions are true. The program will resume otherwise.

func (*Watchpoint) Display

func (self *Watchpoint) Display(nameValuePairs ...interface{}) *Watchpoint

Display sends variable name,value pairs to the debugger. The parameter nameValuePairs must be even sized.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL