Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json2: experiment with go-json-experiment #2021

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5,077 changes: 5,077 additions & 0 deletions internal/json/bundle.go

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions internal/json/bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# Bundle the go-json-experiment package(s)
set -e
find . -name bundle.go -delete

upstream='github.com/go-json-experiment'
root="$(go list -m)/internal"
pkglist='json/internal/jsonflags json/internal/jsonopts json/internal/jsonwire json/internal json/jsontext json'
for pkg in $pkglist; do
maparg="${maparg}${maparg+ }-import=${upstream}/${pkg}=${root}/${pkg}"
done

for pkg in $pkglist; do
dir=$(echo "$pkg" | sed 's,^json,.,')
mkdir -p "$dir"
echo "package $(basename "$pkg")" > "${dir}/temp.go"
eval "go run golang.org/x/tools/cmd/bundle -prefix '' $maparg -dst ${root}/${pkg} ${upstream}/${pkg} > _bundle.go"
mv _bundle.go "${dir}/bundle.go"
done

find . -name temp.go -delete
3 changes: 3 additions & 0 deletions internal/json/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package json

//go:generate sh bundle.sh
15 changes: 15 additions & 0 deletions internal/json/internal/bundle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

197 changes: 197 additions & 0 deletions internal/json/internal/jsonflags/bundle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.