Giter VIP home page Giter VIP logo

larix's Introduction

#1. larix 老K的golang lib库

#2 debug 继承自老K以前的lib-go里实现的 vardump函数

##2.1 VarDump 类似PHP的var_dump函数的debug函数,用于输出当前变量的类型及值, 特点如下:

  1. 递归地输出变量的所有成员类型及值
  2. 采用4空格来缩进,同一缩进级别表示同一层次的变量
  3. 对于指针,会在同一行解引用,显示指针指向的数据结构
  4. 对于数组、切片、映射、字符串等类型,会显示其长度
  5. 在切片、数组、映射结尾,会有结束标记 //end $type

特殊标记说明:

  • -->, 表示指针解引用
  • ==>, 表示数组、切片、映射、字符串等类型的值
  • :, 表示纯量变量或者结构体的成员等
  • (), 注释数组、切片、映射、字符串的长度

使用方法

var cfg *Conf = &Conf{}
err = yaml.Unmarshal(data, cfg)
if err != nil {
    return err
}
kdebug.VarDump(cfg)

输出:
[*main.Conf] --> struct[main.Conf] ==> {
    [*main.Person] --> struct[main.Person] ==> {
        Name [string](6) ==> "peter"
        Height [int] : 180
        Weight [int] : 100
    } //end struct
    slice[[]*main.Person](2) ==>
        [*main.Person] --> struct[main.Person] ==> {
            Name [string](2) ==> "p1"
            Height [int] : 111
            Weight [int] : 111
        } //end struct
        [*main.Person] --> struct[main.Person] ==> {
            Name [string](2) ==> "p2"
            Height [int] : 222
            Weight [int] : 222
        } //end struct
    //end slice
} //end struct

larix's People

Contributors

kstrwind avatar

Watchers

 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.