Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions implementations/Golang_github.com-theory-jsonpath/LINK
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/theory/jsonpath
10 changes: 10 additions & 0 deletions implementations/Golang_github.com-theory-jsonpath/build.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = implementations/Golang_github.com-theory-jsonpath
builddir = $root/build

# Hack target directory because golang is bad, again
rule build
command = cd $root && go build -o build/main

build $builddir/main: build | $root/main.go $root/go.mod $root/go.sum

build $root/install: phony $builddir/main
5 changes: 5 additions & 0 deletions implementations/Golang_github.com-theory-jsonpath/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module example.com/main

go 1.23

require github.com/theory/jsonpath v0.10.0
10 changes: 10 additions & 0 deletions implementations/Golang_github.com-theory-jsonpath/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/theory/jsonpath v0.10.0 h1:qjuGwjcWMPfYmhjDnOjP9vmGzISeRzQ/87u2GZIWLoA=
github.com/theory/jsonpath v0.10.0/go.mod h1:yv+crL58A+g3yxLr1sbOyn8H+L/6kS4AMXlXeVGOuNU=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
42 changes: 42 additions & 0 deletions implementations/Golang_github.com-theory-jsonpath/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: GPL-3.0

package main

import (
"encoding/json"
"fmt"
"io"
"os"

"github.com/theory/jsonpath"
)

func main() {
selector := os.Args[1]

data, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

var json_data any
if err := json.Unmarshal([]byte(data), &json_data); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}

path, err := jsonpath.Parse(selector)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}

json_result, err := json.Marshal(path.Select(json_data))
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
fmt.Println(string(json_result))
}
6 changes: 6 additions & 0 deletions implementations/Golang_github.com-theory-jsonpath/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail

readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

"$script_dir"/build/main "$@"
5 changes: 5 additions & 0 deletions implementations/Golang_github.com-theory-jsonpath/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$BASH_SOURCE[0]")"
go get -u