Giter Club home page Giter Club logo

gobugger's Introduction

gobugger

GitHub go.mod Go version of a Go module Go Go Report Card Go Reference GitHub issues GitHub forks GitHub stars GitHub license

With this small library it should be possible to debug easier in json files. Instead of always using the console.

Install

go get github.com/gowizzard/gobugger

How to use?

Actually, the library is super simple. You start a logging process and feed it with data via another function. If you want to stop the debugging, then there is also a function for this. Now the data is stored in a folder structure directly at the desired location.

Here you will find an example:

// Create new debugger
debugger := gobugger.Config{
    Path: "/Users/jonaskwiedor/Downloads",
}

// Start debugger
debugger.Start()

// Add test data with a struct
testDataStruct := TestStruct{
    Name:        "Outdoor Elements™ II Flannel Shirt für Männer",
    Sku:         "outdoor-elements-ii-flannel-shirt-fur-manner-1959661",
    Price:       "79,99",
    Color:       "Canyon Gold Oversize Tartan",
    Size:        "XL",
    Description: "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look.",
}

debugger.Add(testDataStruct)

// End debugger
err := debugger.End()
if err != nil {
    fmt.Println(err)
}

The whole thing is now saved in a JSON file and looks like this:

{
    "debugger": "gobugger",
    "start": "2021-11-13T13:09:26.972983+01:00",
    "end": "2021-11-13T13:09:26.972983+01:00",
    "data": [
        {
            "name": "Outdoor Elements™ II Flannel Shirt für Männer",
            "sku": "outdoor-elements-ii-flannel-shirt-fur-manner-1959661",
            "price": "79,99",
            "color": "Canyon Gold Oversize Tartan",
            "size": "XL",
            "description": "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look."
        }
    ]
}

The nice thing is that you can also debug a wide variety of data types. Here is a larger example:

// Create new debugger
debugger := gobugger.Config{
    Path: "/Users/jonaskwiedor/Downloads",
}

// Start debugger
debugger.Start()

// Add test data with a map
testDataMap := make(map[string]interface{})

testDataMap["Name"] = "Outdoor Elements™ II Flannel Shirt für Männer"
testDataMap["Sku"] = "outdoor-elements-ii-flannel-shirt-fur-manner-1959661"
testDataMap["Price"] = "79,99"
testDataMap["Color"] = "Canyon Gold Oversize Tartan"
testDataMap["Size"] = "XL"
testDataMap["Description"] = "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look."

debugger.Add(testDataMap)

// Add test data with an array
testDataArray := []string{
    "Outdoor Elements™ II Flannel Shirt für Männer",
    "outdoor-elements-ii-flannel-shirt-fur-manner-1959661",
    "79,99",
    "Canyon Gold Oversize Tartan",
    "XL",
    "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look.",
}

debugger.Add(testDataArray)

// Add test data with a struct
testDataStruct := TestStruct{
    Name:        "Outdoor Elements™ II Flannel Shirt für Männer",
    Sku:         "outdoor-elements-ii-flannel-shirt-fur-manner-1959661",
    Price:       "79,99",
    Color:       "Canyon Gold Oversize Tartan",
    Size:        "XL",
    Description: "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look.",
}

debugger.Add(testDataStruct)

// End debugger
err := debugger.End()
if err != nil {
    fmt.Println(err)
}

The whole thing then looks like this when you look at the debug file:

{
    "debugger": "gobugger",
    "start": "2021-11-13T13:09:26.972983+01:00",
    "end": "2021-11-13T13:09:26.972983+01:00",
    "data": [
        {
            "Color": "Canyon Gold Oversize Tartan",
            "Description": "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look.",
            "Name": "Outdoor Elements™ II Flannel Shirt für Männer",
            "Price": "79,99",
            "Size": "XL",
            "Sku": "outdoor-elements-ii-flannel-shirt-fur-manner-1959661"
        },
        [
            "Outdoor Elements™ II Flannel Shirt für Männer",
            "outdoor-elements-ii-flannel-shirt-fur-manner-1959661",
            "79,99",
            "Canyon Gold Oversize Tartan",
            "XL",
            "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look."
        ],
        {
            "name": "Outdoor Elements™ II Flannel Shirt für Männer",
            "sku": "outdoor-elements-ii-flannel-shirt-fur-manner-1959661",
            "price": "79,99",
            "color": "Canyon Gold Oversize Tartan",
            "size": "XL",
            "description": "Mit seinem traditionellen Karomuster, dem klassischen Kragen und den langen Ärmeln bringt dir dieses Hemd einen Casual-Look."
        }
    ]
}

gobugger's People

Contributors

gowizzard avatar

Stargazers

Jordan 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.