Golang debug dump and die (dd)

Install

go get github.com/serhankarakoc/godd

Usage

Dump Struct:

package main

import (
	"github.com/serhankarakoc/godd"
)

func main() {
	type Animal struct {
		Name string
		Age  int
	}

	leo := Animal {
		Name: "leo",
		Age:  5,
	}
	godd.DD(leo)
}

// result
Type: main.Animal
Main Type: struct
Value: {leo 5}

Dump Strings:

package main

import (
	"github.com/serhankarakoc/godd"
)

func main() {
	t := "test string"
	godd.DD(t)
}

// result
Type: string
Value: test string

Dump Numeric:

package main

import (
	"github.com/serhankarakoc/godd"
)

func main() {
	t := 123.45
	godd.DD(t)
}

// result
Type: float64
Value: 123.45

Dump Channel:

package main

import (
	"github.com/serhankarakoc/godd"
)

func main() {
	var c chan int
	godd.DD(c)
}

// result
Type: chan int
Main Type: chan
Value: <nil>

Dump Interface:

package main

import (
	"github.com/serhankarakoc/godd"
)

func main() {
	type Getter interface {
		get()
	}
	var g Getter
	godd.DD(g)
}

// result
Type: interface

GitHub

View Github