go_transform

command module
v0.0.0-...-ed8b110 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: MIT Imports: 4 Imported by: 0

README

# go_transform

A tiny command‑line utility written in Go that applies a JSON "transform" to one or more target JSON files. The transform file declares a special key "__targets" listing the files to modify; the rest of the JSON is merged into each target. Results overwrite the original target files.

Overview

  • Language/Stack: Go (Go modules)
  • Module name: github.com/polakv93/go_transform (see go.mod)
  • Entry point: main.go
  • Package manager/build tool: Go toolchain (no external dependencies)

How it works:

  1. You provide a path to a JSON transform file.
  2. The transform file contains:
    • A special "__targets" array of file paths to JSON files to update.
    • Any additional keys/values that will be merged into each target JSON file.
  3. Each target JSON is read, merged (deep merge for nested objects), and written back to the same file.

Example transform file:

{
  "__targets": [
    "exampleFiles/target1.json",
    "exampleFiles/target2.json"
  ],
  "somekey": "somevalue2"
}

Requirements

  • Go 1.25 or newer (per go.mod). The project was authored against go 1.25.
  • A shell/terminal on your OS (Windows, macOS, or Linux). This repository is confirmed on Windows paths; forward slashes in JSON paths are also accepted by Go on Windows.

Setup

No special setup is required beyond having Go installed.

  • Verify Go installation:

    • go version
    • go env GOPATH
  • Pull dependencies:

    • go mod tidy (optional; go.mod currently has no third‑party requirements)

Build and Run

You can run directly without building a binary:

  • Run:
    • go run . <path-to-transform.json>
    • Example: go run . exampleFiles/transform.json

Or build a binary first:

  • Build:

    • On Windows: go build -o go_transform.exe .
    • On macOS/Linux: go build -o go_transform .
  • Run the built binary:

    • Windows: ./go_transform.exe exampleFiles/transform.json
    • macOS/Linux: ./go_transform exampleFiles/transform.json

Install from a repository URL

go install github.com/polakv93/go_transform@latest
After installation, the binary (go_transform) will be placed in GOPATH/bin or GOBIN if set.

CLI help

  • go run . -help
  • Or with a built binary: ./go_transform -help

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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