pathify

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README

GitHub Release Go Reference go.mod License Build Status CodeQL

Pathify

The swiss knife to deal with the hassle of unstructured data.

History and project status

This module is already ready-for-production and the astrokube organization already take advantage of it for our internal projects.

Pathify Highlights

  • Easy integration: It's straightforward to be integrated with your current developments.

Installation

Use go get to retrieve the library to add it to your GOPATH workspace, or project's Go module dependencies.

go get -u github.com/astrokube/pathifier

To update the library use go get -u to retrieve the latest version of it.

go get -u github.com/astrokube/pathifier

You could specify a concrete version of this module as It's shown on the below. Replace x.y.z by the desired version.

module github.com/<org>/<repository>
require ( 
  github.com/astrokube/pathifier vX.Y.Z
)

Getting started

Pre-requisites
  • Go 1.19+
Examples

A rich and growing set of examples of usage of this module can be found in folder examples.

package main

import (
	"strings"

	"github.com/astrokube/pathify"
)

var peopleArray = []any{
	map[string]any{
		"firstname": "John",
		"lastname":  "Doe",
		"age":       29,
	},
	map[string]any{
		"firstname": "Jane",
		"lastname":  "Moe",
		"age":       30,
	},
}

func main() {
	p := pathify.Load[[]any](peopleArray).Set(
		"[1].lastname", "Doe",
		"[0].firstname", "Wendy",
		"[2].firstname", "Cindy",
		"[1].firstname", strings.ToUpper,
	)
	b, _ := p.YAML()
	println(string(b))
	b, _ = p.JSON()
	println(string(b))
}

Output

- age: 29
  firstname: Wendy
  lastname: Doe
- age: 30
  firstname: JANE
  lastname: Doe
- firstname: Cindy
[{"age":29,"firstname":"Wendy","lastname":"Doe"},{"age":30,"firstname":"JANE","lastname":"Doe"},{"firstname":"Cindy"}]
Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load added in v0.0.2

func Load[S pathifier.Type](content S, opts ...pathifier.PathifyOpt) pathifier.Pathifier[S]

func New

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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