typebrowser

package module
v0.0.0-...-2b3eadb Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2013 License: MPL-2.0 Imports: 7 Imported by: 0

README

typebrowser

View type information from your program in your browser!

Typebrowser is a modern variant of println-debugging. Instead of debug outputs on some lines scrolling faster than you can say ... anything, it conviniently stops everything to let you see what's happening inside.

For now, this is restricted to type information.

How do I use this?

Call NewTypeServer and stuff things into the channel. Open your browser and point it to the port you specify. It's pretty simple.

import (
	// import it
	"github.com/arnehormann/typebrowser"
)

// start it
var typechan = typebrowser.NewTypeServer(":8080")

...
	// use it - feed anything to it!
	typechan <- myvar
	// if you want to know where in your program this is called from:
	typechan <- typebrowser.Type{myvar, `some file, some line, some state`}
...

Typebrowser can be installed by go get github.com/arnehormann/typebrowser.

It depends on mirror, go-gettable with go get github.com/arnehormann/mirror.

When you use it, it shows a site with one button per export format. The next type is fetched with an http-post, your program stops because it blocks on the channel read until the next type is requested.

For a working code example, see example/example.go.

For a peek at what the html output looks like, see this demo for *reflect.StructField.

Types containing others are foldable on click.

JSON output is next on my agenda.

License: MPL2.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTypeServer

func NewTypeServer(addr string) chan<- interface{}

NewTypeServer creates a new type server listening on the specified address. The address format matches that of http.ListenAndServe. You get a channel you can stuff things into. Point your browser to the address and fill the channel with values you want to inspect.

Types

type Type

type Type struct {
	Value   interface{}
	Message string
}

Type is used to transport a message in addition to a type. Pass an instance to get a better overview which part of your code a type comes from.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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