Git Product home page Git Product logo

tree's Introduction

#Print object as a tree when debugging

How to use

go get github.com/Maxgis/tree
import ("github.com/Maxgis/tree")

tree.Print(ob)

##Print Example


type People struct {
    Name string
	Age  int
	sex  string

	Father   *People
	Children []*People
	Pro      map[string]string
}

func Test_print(t *testing.T) {
	fa := &People{Name: "jim", Age: 44, sex: "man"}
	fa.Pro = make(map[string]string)
	fa.Pro["city"] = "Beijing"
	son := &People{Name: "jimson", Age: 12, sex: "boy"}
	daughter := &People{Name: "jimdaughter", Age: 14, sex: "girl"}
	fa.Children = make([]*People, 2)
	fa.Children[0] = son
	fa.Children[1] = daughter
	son.Father = fa
	Print(fa)
	fmt.Printf("%#v\n", fa)
}

{
  Name:string("jim"),
  Age:int(44),
  sex:string("man"),
  Father:*tree.People(nil),
  Children:[
    {
      Name:string("jimson"),
      Age:int(12),
      sex:string("boy"),
      Father:*tree.People(c8200980f0,reference to each other),
      Children:[],
      Pro:{}(map[string]string)
    }(*tree.People),
    {
      Name:string("jimdaughter"),
      Age:int(14),
      sex:string("girl"),
      Father:*tree.People(nil),
      Children:[],
      Pro:{}(map[string]string)
    }(*tree.People)
  ],
  Pro:{
    city:string("Beijing")
  }(map[string]string)
}(*tree.People)

Original Print

&tree.People{Name:"jim", Age:44, sex:"man", Father:(*tree.People)(nil), Children:[]*tree.People{(*tree.People)(0xc820014280), (*tree.People)(0xc8200142d0)}, Pro:map[string]string{"city":"Beijing"}}

tree's People

Contributors

markismark avatar maxgis avatar

Stargazers

 avatar 沉没捕鱼 avatar hengjiang ly avatar liwei avatar  avatar happyEgg avatar  avatar  avatar Kevin Liu avatar Daffy Weng avatar Z.X.PING avatar heimeil avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.