structator

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 2 Imported by: 0

README ΒΆ

Go GitHub go.mod Go version Go Report Card codecov License Ask Me Anything ! Github tag

Overview

Structator is simple tool for copy specific fields a new struct, including metadata.

Features

  • Simple
  • Coverage
  • Compatible with slice
  • Tag copy
Usage
package main

import (
    "github.com/lab210-dev/structator"
    "log"
)

type Foo struct {
    Counter int    `json:"int"`
    Value   string `json:"value"`
    Struct  Bar    `json:"struct"`
    Slice   []Bar  `json:"Slice"`
}

type Bar struct {
    Value string `json:"value"`
}

func main() {
    payload := Foo{Value: "foo", Struct: Bar{Value: "bar"}}
    log.Printf("%v", structator.From(payload, "Value", "Struct.Bar")) 
    // print: {Value:foo Struct:{Value:bar}}
}

🀝 Contributions

Contributors to the package are encouraged to help improve the code.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func From ΒΆ

func From(source any, fields ...string) any

Types ΒΆ

This section is empty.

Jump to

Keyboard shortcuts

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